Stephan, Frank wrote:
> Hi,
> 
> I use writer_emb.setPDFXConformance(PdfWriter.PDFA1B); now and i get no 
> exception, but I still get the error messages when I validate the PDF with 
> SolidFramework.
> 
> The key 'Metadata' is required for PDF object 'Catalog'
> Device-specific color space used with incorrect or missing OutputIntent

public void createPdfA(String filename)
throws IOException, DocumentException {
   // step 1
   Document document = new Document();
   // step 2
   PdfWriter writer = PdfWriter.getInstance(document,
     new FileOutputStream(filename));
   writer.setTagged();
   writer.setPDFXConformance(PdfWriter.PDFA1A);
   writer.createXmpMetadata();
   // step 3
   document.open();
   // step 4
   PdfDictionary oi = new PdfDictionary(PdfName.OUTPUTINTENT);
   oi.put(PdfName.OUTPUTCONDITIONIDENTIFIER,
     new PdfString("sRGB IEC61966-2.1"));
   oi.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
   oi.put(PdfName.S, PdfName.GTS_PDFA1);
   ICC_Profile icc = ICC_Profile.getInstance(
     new FileInputStream(PROFILE));
   PdfICCBased icc_based = new PdfICCBased(icc);
   icc_based.remove(PdfName.ALTERNATE);
   oi.put(PdfName.DESTOUTPUTPROFILE,
   writer.addToBody(icc_based).getIndirectReference());
   writer.getExtraCatalog().put(PdfName.OUTPUTINTENTS, new PdfArray(oi));
   Font font = FontFactory.getFont(
     FONT, BaseFont.CP1252, BaseFont.EMBEDDED);
   document.add(new Paragraph("Hello World", font));
   // step 5
   document.close();
}

Yes, I know, iText throws an exception when you're doing something wrong 
but it doesn't throw an exception if you're forgetting XMP metadata or 
the Output Intent. The above example shows one of my own examples that 
works.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to