You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Guillaume Bailleul <gb...@gmail.com> on 2013/01/12 10:17:49 UTC
Creating a PDF/A with PDFBOX
Hi,
I am trying to create a simple PDF/A with PDFBox and I am facing a
ColorSpace problem. I attach the source code to the mail. The
important part of the source is below [3].
The document is generated without error. It is readable with acrobat
reader. But it is considered as an invalid PDF/A with callas validator
[2] because the output intent is not defined [1].
Is there some documentation or examples on how to integrate
outputintent in my document ?
Thanks for your help,
Guillaume
[1] Callas returned error :
Colors are not defined as neutral, and therefore do not always
appear the same.
Device process color used but no PDF/A OutputIntent (1 match on 1 page)
- Text BitstreamVeraSans-Roman 12.0 pt TrueType embedded (1 match)
[2] Callas online demo
http://www.datalogics.com/products/callas/callaspdfA-onlinedemo.asp
[3] The important part of the source :
doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage( page );
PDFont font = PDTrueTypeFont.loadTTF(doc,
"../pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/ArialMT.ttf");
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 = doc.getDocumentCatalog();
PDMetadata metadata = new PDMetadata(doc);
cat.setMetadata(metadata);
// jempbox version
XMPMetadata xmp = new XMPMetadata();
XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp);
xmp.addSchema(pdfaid);
pdfaid.setConformance("B");
pdfaid.setPart(1);
pdfaid.setAbout("");
metadata.importXMPMetadata(xmp);
doc.save( file );
Re: Creating a PDF/A with PDFBOX
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
you would need to include an OutputIntents entry into the DocumentCatalog. I think at that point in time there is no high level API for that.
A sample entry would look like this (Generated by Acrobat X)
(COSName{OutputIntents}:COSArray{[COSDictionary{(COSName{DestOutputProfile}:COSDictionary{(COSName{Filter}:COSName{FlateDecode}) (COSName{Length}:COSInt{2574}) (COSName{N}:COSInt{3}) (COSName{Range}:COSArray{[COSFloat{0.0}, COSFloat{1.0}, COSFloat{0.0}, COSFloat{1.0}, COSFloat{0.0}, COSFloat{1.0}]}) }) (COSName{Info}:COSString{sRGB IEC61966-2.1}) (COSName{OutputCondition}:COSString{}) (COSName{OutputConditionIdentifier}:COSString{Custom}) (COSName{RegistryName}:COSString{http://www.color.org}) (COSName{S}:COSName{GTS_PDFA1}) (COSName{Type}:COSName{OutputIntent}) }]}).
Kind regards
Maruan Sahyoun
Am 12.01.2013 um 10:17 schrieb Guillaume Bailleul <gb...@gmail.com>:
> Hi,
>
> I am trying to create a simple PDF/A with PDFBox and I am facing a
> ColorSpace problem. I attach the source code to the mail. The
> important part of the source is below [3].
>
> The document is generated without error. It is readable with acrobat
> reader. But it is considered as an invalid PDF/A with callas validator
> [2] because the output intent is not defined [1].
>
> Is there some documentation or examples on how to integrate
> outputintent in my document ?
>
> Thanks for your help,
>
> Guillaume
>
>
> [1] Callas returned error :
> Colors are not defined as neutral, and therefore do not always
> appear the same.
> Device process color used but no PDF/A OutputIntent (1 match on 1 page)
> - Text BitstreamVeraSans-Roman 12.0 pt TrueType embedded (1 match)
>
> [2] Callas online demo
> http://www.datalogics.com/products/callas/callaspdfA-onlinedemo.asp
>
> [3] The important part of the source :
>
> doc = new PDDocument();
>
> PDPage page = new PDPage();
> doc.addPage( page );
>
> PDFont font = PDTrueTypeFont.loadTTF(doc,
> "../pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/ArialMT.ttf");
>
> 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 = doc.getDocumentCatalog();
> PDMetadata metadata = new PDMetadata(doc);
> cat.setMetadata(metadata);
>
> // jempbox version
> XMPMetadata xmp = new XMPMetadata();
> XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp);
> xmp.addSchema(pdfaid);
> pdfaid.setConformance("B");
> pdfaid.setPart(1);
> pdfaid.setAbout("");
> metadata.importXMPMetadata(xmp);
>
> doc.save( file );