pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Attachment not always visible
Date Thu, 01 Feb 2018 17:14:26 GMT
Please upload both files to a sharehoster, so that we can look at the 
differences with PDFDebugger, compare with the PDF specification, and 
decide whether it's a bug or not.

Tilman

Am 01.02.2018 um 09:33 schrieb Robert Nemet:
> 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: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message