Hi,
I’m looking for a help with embeded pdf into other pdf-file using pdfbox lib .
When perform veraPDF verification newly created pdf file  I get:



Have you got an idea what I’m doing wrong or I can give me any suggestion how I 
can solve it ?
(the same file chcked on https://www.pdf-online.com/osa/validate.aspx passes 
the validation but with info:

The document's meta data is either missing or inconsistent or corrupt.

The document does conform to the PDF/A-2b standard.

So I assume that I’m doing something wrong 😐

VeraPdf response:

Validation Report
File:

C:\Workspace\BundesArchive\Git\webscan-core\webscan-rendition-fragment\target\test-workspace\pdf-embedding-target\embedded-pdf.pdf

Validation Profile:

PDF/A-2B validation profile

PDF/A compliance:

Failed

Statistics
Version:

1.9.84

Build Date:

2017-11-29T15:10:00+01:00

Processing time:

00:00:01.666

Total rules in Profile:

121

Passed Checks:

36455

Failed Checks:

4

Validation information
Rule

Status

Specification: ISO 19005-2:2011, Clause: 6.2.11.4, Test number: 
4<https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Parts-2-and-3-rules#rule-62114-4>

If the FontDescriptor dictionary of an embedded CID font contains a CIDSet 
stream, then it shall identify all CIDs which are present in the font program, 
regardless of whether a CID in the font is referenced or used by the PDF or not.

Failed

1 occurrences

Show


Specification: ISO 19005-2:2011, Clause: 6.8, Test number: 
1<https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Parts-2-and-3-rules#rule-68-1>

A file specification dictionary, as defined in ISO 32000-1:2008, 7.11.3, may 
contain the EF key, provided that the embedded file is compliant with either 
ISO 19005-1 or this part of ISO 19005.

Failed

2 occurrences

Show


Specification: ISO 19005-2:2011, Clause: 6.4.3, Test number: 
1<https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Parts-2-and-3-rules#rule-643-1>

When computing the digest for the file, it shall be computed over the entire 
file, including the signature dictionary but excluding the PDF Signature itself.

Failed

1 occurrences

Show







Here is my code:

private void embeddPdfs(DocumentRenditionConfiguration 
documentRenditionConfiguration, PDDocument destination, List<Map.Entry<String, 
PDDocument>> entries) throws IOException {
    PDFMergerUtility ut = new PDFMergerUtility();
    boolean first = true;
    Map embeddedFileMap = new HashMap();
    for (Map.Entry<String, PDDocument> entry : entries) {
        if (first) {
            first = false;
            ut.appendDocument(destination, entry.getValue());
        } else {
            //first create the file specification, which holds the embedded file
            try (ByteArrayOutputStream bout = new ByteArrayOutputStream()) {
                entry.getValue().save(bout);
                byte[] bytes = bout.toByteArray();
                try (InputStream in = new ByteArrayInputStream(bytes); 
PDDocument embeddedDestination = 
createEmptyPDDocument(documentRenditionConfiguration.getRenditionOptions().getResultType()))
 {
                    PDDocument embeddedDocument = PDDocument.load(in);
                    ut.appendDocument(embeddedDestination, embeddedDocument);
                    try (ByteArrayOutputStream embeddedBout = new 
ByteArrayOutputStream()) {
                        embeddedDestination.save(embeddedBout);
                        byte[] embeddedBytes = embeddedBout.toByteArray();
                        try (InputStream embeddedIn = new 
ByteArrayInputStream(embeddedBytes)) {
                            String filename = entry.getKey();
                            PDComplexFileSpecification complexFileSpecification 
= new PDComplexFileSpecification();
                            complexFileSpecification.setFile(filename);
                            COSDictionary dict = 
complexFileSpecification.getCOSObject();
                            dict.setString("UF",filename);
                            PDEmbeddedFile embeddedFile = new 
PDEmbeddedFile(destination, embeddedIn);
                            embeddedFile.setSubtype("application/pdf");
                            embeddedFile.setSize(bytes.length);
                            embeddedFile.setCreationDate(new 
GregorianCalendar());
                            
addEssentialXmpMetadataForPDFA(embeddedDestination,documentRenditionConfiguration);
                            
complexFileSpecification.setEmbeddedFile(embeddedFile);
                            embeddedFileMap.put(filename, 
complexFileSpecification);
                        }
                    }
                }
            }
        }
    }
    addEssentialXmpMetadataForPDFA(destination,documentRenditionConfiguration);
    PDEmbeddedFilesNameTreeNode embeddedFilesTree = new 
PDEmbeddedFilesNameTreeNode();
    embeddedFilesTree.setNames(embeddedFileMap);
    PDDocumentNameDictionary namesDictionary = new 
PDDocumentNameDictionary(destination.getDocumentCatalog());

    namesDictionary.setEmbeddedFiles(embeddedFilesTree);
    destination.getDocumentCatalog().setNames(namesDictionary);
}

Best regards and thanks in advance

Jarek


DXC Technology Company -- This message is transmitted to you by or on behalf of 
DXC Technology Company or one of its affiliates. It is intended exclusively for 
the addressee. The substance of this message, along with any attachments, may 
contain proprietary, confidential or privileged information or information that 
is otherwise legally exempt from disclosure. Any unauthorized review, use, 
disclosure or distribution is prohibited. If you are not the intended recipient 
of this message, you are not authorized to read, print, retain, copy or 
disseminate any part of this message. If you have received this message in 
error, please destroy and delete all copies and notify the sender by return 
e-mail. Regardless of content, this e-mail shall not operate to bind DXC 
Technology Company or any of its affiliates to any order or other contract 
unless pursuant to explicit written agreement or government initiative 
expressly permitting the use of e-mail for such purpose.

Reply via email to