[
https://issues.apache.org/jira/browse/PDFBOX-1564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13630450#comment-13630450
]
Guillaume Bailleul edited comment on PDFBOX-1564 at 4/12/13 6:32 PM:
---------------------------------------------------------------------
This is a patch with the mods proposed by Elyes Lehtihet.
I also added a running simple example.
I did not push the icc file because I am not sure we can put it in apache
artefacts.
I am not sure where to put the new sources, I did :
* DestOutputProfile is in pdmodel.common like other extensions of PDStream
* OutputIntent in pdmodel.graphics.color because it looked a good idea (I
renamed the class)
was (Author: gbm.bailleul):
This is a patch with the mods proposed by Elyes Lehtihet.
I also added a running simple example.
I did not push the icc file because I am not sure we can put it in apache
artefacts.
I am not sure where to put the new sources, I did :
* DestOutputProfile is in pdmodel.common like other extensions of PDStream
* OutputIntent in pdmodel.graphics.color because it looked a good idea.
> Extending COSName to produce PDF/A with correct OutputIntents
> -------------------------------------------------------------
>
> Key: PDFBOX-1564
> URL: https://issues.apache.org/jira/browse/PDFBOX-1564
> Project: PDFBox
> Issue Type: Improvement
> Reporter: Elyes Lehtihet
> Priority: Minor
> Attachments: create-pdfa.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Hello,
> First of all, thanks for this tool, found it very useful.
> Below some sample code to include (sRGB) ICC profile and corresponding
> OutputIntents to the generated PDF/A. The produced PDF successfully
> passes validation.
> It would be nice to have the COSName' extension included in the next
> release so we won't have to use a homemade build.
> Regards,
> Elyes
> ----
> * Extension in COSName (org.apache.pdfbox.cos)
> public static final COSName OutputIntents = new COSName( "OutputIntents" );
> public static final COSName OutputIntent = new COSName( "OutputIntent" );
> public static final COSName DestOutputProfile = new COSName(
> "DestOutputProfile" );
> * Add new classes
> public class OutputIntents implements COSObjectable {
> private COSDictionary dictionary;
> public OutputIntents(PDDocument doc, InputStream colorProfile) throws
> Exception{
> dictionary = new COSDictionary();
> dictionary.setItem(COSName.TYPE, COSName.OutputIntent);
> dictionary.setItem(COSName.S, COSName.GTS_PDFA1);
> DestOutputProfile dop = new DestOutputProfile(doc,colorProfile, false);
> dop.configure();
> dictionary.setItem(COSName.DestOutputProfile, dop);
> }
> public COSBase getCOSObject() {
> return dictionary;
> }
> public COSDictionary getDictionary()
> {
> return dictionary;
> }
> public void setInfo( String value )
> {
> dictionary.setString("Info", value);
> }
> public void setOutputCondition( String value )
> {
> dictionary.setString("OutputCondition", value);
> }
> public void setOutputConditionIdentifier( String value )
> {
> dictionary.setString("OutputConditionIdentifier", value);
> }
> public void setRegistryName( String value )
> {
> dictionary.setString("RegistryName", value);
> }
> }
> public class DestOutputProfile extends PDStream {
> public DestOutputProfile(PDDocument document) {
> super(document);
> }
> public DestOutputProfile(COSStream str) {
> super(str);
> }
> public DestOutputProfile(PDDocument doc, InputStream str)
> throws IOException {
> super(doc, str);
> }
> public DestOutputProfile(PDDocument doc, InputStream str, boolean filtered)
> throws IOException {
> super(doc, str, filtered);
> }
> public void configure(){
> try {
> getStream().setFilters(COSName.FLATE_DECODE);
> getStream().setInt( COSName.LENGTH, getByteArray().length );
> getStream().setInt(COSName.N, 3);
> addCompression();
> }
> catch (Exception e) {
> e.printStackTrace();
> System.exit(-1);
> }
> }
> }
> * Sample code to include output intent
> PDDocumentCatalog cat = doc.getDocumentCatalog();
> COSDictionary root = (COSDictionary)cat.getCOSObject();
> /* Here you have to download .icc profile */
> InputStream colorProfile =
> OutputIntents.class.getResourceAsStream("/test/color/sRGB.icc");
> OutputIntents oi = new OutputIntents(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");
> COSArray outputIntents = new COSArray();
> outputIntents.add(oi);
> root.setItem("OutputIntents", outputIntents);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira