Hi,

I have two pdf files and they should be same( some text and attachment).
One is created with PDFBox while other with iText ( old one, and we are
trying to migrate from it ).

Issue is that if I open iText pdf in browser ( chrome with PDF Viewer ) I
see document and attachment, but if I open pdf created with PDFBox
attachment is not visible. In Acrobat Reader desktop it is visible.
I wonder why is that and if it is possible to be the same?

Here is a code how attachments are added:

=====

final PDDocument document = PDDocument.load(result);
        final Map<String, PDComplexFileSpecification> embeddedFileMap = new
HashMap<String, PDComplexFileSpecification>();
        final List<File> tmpFiles = new ArrayList<File>();

        for( TitledDocument attachment: attachments ) {
            InputStream is;
            if( memoryUsageSetting.isMainMemoryRestricted() ) {
                is = new ByteArrayInputStream(attachment.getData());
            } else {
                try {
                    // drop attachments on file system
                    File tempFile =
TempFile.dumpBufferToTempFile(attachment.getData(),
attachment.getMimeType());
                    tmpFiles.add(tempFile);
                    is = new FileInputStream(tempFile);
                } catch (IOException ex) {
                    is = new ByteArrayInputStream(attachment.getData());
                }

            }
            PDEmbeddedFile ef = new PDEmbeddedFile(document, is);
            // create embeded file
            ef.setSubtype(attachment.getMimeType().getMimeString());
            ef.setSize(attachment.getSize());
            // file spec
            PDComplexFileSpecification fs = new
PDComplexFileSpecification();
            fs.setFile(attachment.getTitleWithExtension());
            fs.setEmbeddedFile(ef);

            embeddedFileMap.put(attachment.getTitle(), fs);
        }

        final PDEmbeddedFilesNameTreeNode efTree = new
PDEmbeddedFilesNameTreeNode();
        efTree.setNames(embeddedFileMap);

        final PDDocumentNameDictionary names = new
PDDocumentNameDictionary(document.getDocumentCatalog());
        names.setEmbeddedFiles(efTree);
        document.getDocumentCatalog().setNames(names);

        document.save(output);
        document.close();

=====

Actually, it is same in every browser I tried ( chrome, firefox, IE ).


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

Reply via email to