pdfa3-sample/src/main/java/pdfbox/PDFA3File.java
public void doIt(String file, String message) throws Exception
  {
    // the document
    PDDocument doc = null;
    try
    {
      doc = new PDDocument();

      // now create the page and add content
      PDPage page = new PDPage();

      doc.addPage(page);

      InputStream fontStream = PDFA3File.class.getResourceAsStream("/Ubuntu-R.ttf");
      PDFont font = PDTrueTypeFont.loadTTF(doc, fontStream);

      // create a page with the message where needed
      PDPageContentStream contentStream = new PDPageContentStream(doc, page);
      contentStream.beginText();
      contentStream.setFont(font, 12);
      contentStream.moveTextPositionByAmount(100, 700);
      contentStream.drawString(message);
      contentStream.endText();
      contentStream.saveGraphicsState();
      contentStream.close();

      PDDocumentCatalog cat = makeA3compliant(doc);

      InputStream colorProfile = PDFA3File.class.getResourceAsStream("/sRGB Color Space Profile.icm");

      // create output intent
      PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
      oi.setInfo("sRGB IEC61966-2.1");
      oi.setOutputCondition("sRGB IEC61966-2.1");
      oi.setOutputConditionIdentifier("sRGB IEC61966-2.1");
      oi.setRegistryName("http://www.color.org");
      cat.addOutputIntent(oi);

      doc.save(file);

    }
    finally
    {
      if (doc != null)
      {
        doc.close();
      }
    }
  }
/**
   * Create a simple PDF/A-3 document.
   * This example is based on HelloWorld example.
   * As it is a simple case, to conform the PDF/A norm, are added : - the font
   * used in the document - the sRGB color profile - a light xmp block with only
   * PDF identification schema (the only mandatory) - an output intent To
   * conform to A/3 - the mandatory MarkInfo dictionary displays tagged PDF
   * support - and optional producer and - optional creator info is added
   * 
   * @param file
   *          The file to write the PDF to.
   * @param message
   *          The message to write in the file.
   * @throws Exception
   *           If something bad occurs
   */
Create a simple PDF/A-3 document.
This example is based on HelloWorld example.

@param file
The file to write the PDF to.
@param message
The message to write in the file.
@throws Exception
If something bad occurs
Create a simple PDF / A - 3 document . This example is based on HelloWorld example . @param file The file to write the PDF to . @param message The message to write in the file . @throws Exception If something bad occurs
public void doIt(String file, String message) throws Exception
  {
    PDDocument doc = null;
    try
    {
      doc = new PDDocument();
      PDPage page = new PDPage();
      doc.addPage(page);
      InputStream fontStream = PDFA3File.class.getResourceAsStream("/Ubuntu-R.ttf");
      PDFont font = PDTrueTypeFont.loadTTF(doc, fontStream);
      PDPageContentStream contentStream = new PDPageContentStream(doc, page);
      contentStream.beginText();
      contentStream.setFont(font, 12);
      contentStream.moveTextPositionByAmount(100, 700);
      contentStream.drawString(message);
      contentStream.endText();
      contentStream.saveGraphicsState();
      contentStream.close();
      PDDocumentCatalog cat = makeA3compliant(doc);
      InputStream colorProfile = PDFA3File.class.getResourceAsStream("/sRGB Color Space Profile.icm");
      PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
      oi.setInfo("sRGB IEC61966-2.1");
      oi.setOutputCondition("sRGB IEC61966-2.1");
      oi.setOutputConditionIdentifier("sRGB IEC61966-2.1");
      oi.setRegistryName("http://www.color.org");
      cat.addOutputIntent(oi);
      doc.save(file);
    }
    finally
    {
      if (doc != null)
      {
        doc.close();
      }
    }
  }
public void doIt ( String file , String message ) throws Exception { PDDocument doc = null ; try { doc = new PDDocument ( ) ; PDPage page = new PDPage ( ) ; doc . addPage ( page ) ; InputStream fontStream = PDFA3File . class . getResourceAsStream ( "/Ubuntu-R.ttf" ) ; PDFont font = PDTrueTypeFont . loadTTF ( doc , fontStream ) ; PDPageContentStream contentStream = new PDPageContentStream ( doc , page ) ; contentStream . beginText ( ) ; contentStream . setFont ( font , 12 ) ; contentStream . moveTextPositionByAmount ( 100 , 700 ) ; contentStream . drawString ( message ) ; contentStream . endText ( ) ; contentStream . saveGraphicsState ( ) ; contentStream . close ( ) ; PDDocumentCatalog cat = makeA3compliant ( doc ) ; InputStream colorProfile = PDFA3File . class . getResourceAsStream ( "/sRGB Color Space Profile.icm" ) ; PDOutputIntent oi = new PDOutputIntent ( doc , colorProfile ) ; oi . setInfo ( "sRGB IEC61966-2.1" ) ; oi . setOutputCondition ( "sRGB IEC61966-2.1" ) ; oi . setOutputConditionIdentifier ( "sRGB IEC61966-2.1" ) ; oi . setRegistryName ( "http://www.color.org" ) ; cat . addOutputIntent ( oi ) ; doc . save ( file ) ; } finally { if ( doc != null ) { doc . close ( ) ; } } }
Create a simple PDF/A-3 document.
Create a simple PDF / A - 3 document .
// the document // now create the page and add content // create a page with the message where needed // create output intent