title: Creating a new PDF document using PDFBOX API
body: <p>I need to create a PDF which will hold the report of execution status, where the status would be in table structure. Is it possible to generate pdf table format with the PDFBOX api?</p>
  
  <p>Here is some sample code for creating a new PDF document:</p>
  
  <pre><code>import java.awt.Color;
  import java.io.IOException;
  import org.apache.pdfbox.exceptions.COSVisitorException;
  import org.apache.pdfbox.pdmodel.PDDocument;
  import org.apache.pdfbox.pdmodel.PDPage;
  import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
  import org.apache.pdfbox.pdmodel.font.PDFont;
  import org.apache.pdfbox.pdmodel.font.PDType1Font;
  
  
  
  public class HelloWorld
  {
      /**
       * Constructor.
       */
      public HelloWorld()
      {
          super();
      }
  
  
      public static void main(String[] args) throws IOException, COSVisitorException
      {
          PDDocument doc = null;
      try
      {
          doc = new PDDocument();
  
          PDPage page = new PDPage();
          doc.addPage( page );
          PDFont font = PDType1Font.COURIER_BOLD_OBLIQUE;
          Color color = Color.blue; 
  
  
          PDPageContentStream contentStream = new PDPageContentStream(doc, page);
          contentStream.beginText();
          contentStream.setFont( font, 12 );
          contentStream.setNonStrokingColor(color);
          contentStream.moveTextPositionByAmount( 100, 700 );
          contentStream.drawString( "message" );
  
          contentStream.setNonStrokingColor(Color.GREEN);
          contentStream.drawString( "Hi" );
  
          contentStream.endText();
          contentStream.close();
          doc.save( "d:\\abc.pdf" );
      }
      finally
      {
          if( doc != null )
          {
              doc.close();
          }
      }
      } 
  }
  </code></pre>