Hi, Here is working pdf: https://www.dropbox.com/s/4wzh3gcmzd1p8jo/working-old%20iText.pdf?dl=0 PdfBox file: https://www.dropbox.com/s/ymdrived4fphjrx/problematic-pdfbox2.pdf?dl=0
Thanks, Robert //robert On Thu, Feb 1, 2018 at 6:14 PM, Tilman Hausherr <thaush...@t-online.de> wrote: > 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-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail: users-h...@pdfbox.apache.org >> > > >