[ 
https://issues.apache.org/jira/browse/PDFBOX-4051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312859#comment-16312859
 ] 

Joerg Neumann commented on PDFBOX-4051:
---------------------------------------

Hi Tilman
We decided to truncate the OutputIntent Array of the destination document to 
the first OutputIntent and added the following code after mergeDocuments:

{code:java}
pdfMerger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
            logger.trace("PDF merge successful, size = {} bytes", 
mergedPDFOutputStream.size());
            //Nachbearbeitung des Ergebnis-Pdfs: Truncaten auf einen einzelnen 
Outputintent
            PDDocument 
toBeCastrated=PDDocument.load(mergedPDFOutputStream.toByteArray());
            List<PDOutputIntent> kastrierteListe=new ArrayList<>();
            
kastrierteListe.add(toBeCastrated.getDocumentCatalog().getOutputIntents().get(0));
            
toBeCastrated.getDocumentCatalog().setOutputIntents(kastrierteListe);
            byte[] result= new PDStream(toBeCastrated).toByteArray();
            return result;
{code}
Unfortunately the resulting document still has two outputintents.
We suspect this is because of the non-existent setter for DocumentCatalog and 
we should use some way clone the catalog for the new document, but there is no 
PdfCloneUtility in version 2.0.6 ...

> Different DestOutputProfiles in OutputIntentArray after 
> PDFMergerUtility.Merge leads to non-conformity
> ------------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-4051
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4051
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.0.6
>            Reporter: Joerg Neumann
>            Priority: Minor
>         Attachments: 2018-01-05 07_14_30-Validation Report.jpg
>
>
> Hi ... not sure if thats a bug or not, so i just shoot:
> Im merging some pdfs that conform to the pdfa-1b standard with 
> PdfMergerUtility.merge.
> The result has to be pdfa-1b conform as well.
> So my code is like
> {code:java}
> public ByteArrayOutputStream merge(final List<InputStream> sources) throws 
> IOException {
>         try (
>             ByteArrayOutputStream mergedPDFOutputStream = new 
> ByteArrayOutputStream();
>             COSStream cosStream = new COSStream()
>         ) {
>             PDFMergerUtility pdfMerger = createPDFMergerUtility(sources, 
> mergedPDFOutputStream);
>             PDDocumentInformation pdfDocumentInfo = 
> createPDFDocumentInfo(TITLE, CREATOR, SUBJECT);
>             PDMetadata xmpMetadata = createXMPMetadata(cosStream, TITLE, 
> CREATOR, SUBJECT);
>             pdfMerger.setDestinationDocumentInformation(pdfDocumentInfo);
>             pdfMerger.setDestinationMetadata(xmpMetadata);
>             
> pdfMerger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());          
>             return mergedPDFOutputStream;
>         } catch (BadFieldValueException | TransformerException e) {
>             throw new IOException("PDF merge problem", e);
>         } finally {
>             for (InputStream source : sources) {
>                 try {
>                     source.close();
>                 } catch (IOException e) {}
>             }
>         }
> {code}
> This works fine if the pdfs come from the same source, e.g. have similar 
> OutputIntents described in their catalogs.
> But when i mix documents that have different OutputIntents like
> {code:java}
> /OutputIntents
> [
> <<
> /Type /OutputIntent
> /S /GTS_PDFA1
> /OutputConditionIdentifier (sRGB)
> /RegistryName (http://www.color.org)
> /DestOutputProfile 36 0 R
> >>
> ]
> {code}
> and 
> {code:java}
> <</OutputIntents[<</Info(Adobe RGB 
> \(1998\))/S/GTS_PDFA1/Type/OutputIntent/DestOutputProfile 1 0 
> R/OutputConditionIdentifier(Adobe RGB \(1998\))>>]/Metadata 16 0 
> R/Type/Catalog/StructTreeRoot 15 0 R/MarkInfo<</Marked true>>/Pages 4 0 R>>
> {code}
> the PdfMergerUtility seems to concat them with different DestOutputProfiles:
> {code:java}
> 4 0 obj
> <<
> /Type /OutputIntent
> /S /GTS_PDFA1
> /OutputConditionIdentifier (sRGB)
> /RegistryName (http://www.color.org)
> /DestOutputProfile 17 0 R
> >>
> endobj
> 5 0 obj
> <<
> /Info (Adobe RGB \(1998\))
> /S /GTS_PDFA1
> /Type /OutputIntent
> /DestOutputProfile 18 0 R
> /OutputConditionIdentifier (Adobe RGB \(1998\))
> >>
> endobj
> {code}
> and therefore its no longer conform thanks to Specification: ISO 
> 19005-1:2005, Clause: 6.2.2
> !2018-01-05 07_14_30-Validation Report.jpg|thumbnail!
> when i manually change the file (with a notepad) from "/DestOutputProfile 18 
> 0 R" to "/DestOutputProfile 17 0 R" the file again gains conformity.
> I might be able to re-parse the merged document as PDDocument and modify the 
> OutputIntent-Array in the Catalog, but i dont think thats how it was intended?
> So am i doing something wrong or should PdfMergerUtility not only get a 
> setter for DocumentInformation and MetaData, but some manual way to influence 
> the Outputintents?
> Thanks already.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to