My code is working, but im getting this warning message on the console:
“Removed /IDTree from /Names dictionary, doesn’t belong there”
I’ve just searched about it, but i didn’t find anything. Does someone know what can be causing this warning message?
My code:
public static void abrirArquivoZipPdfCompleto(HttpServletResponse response, String fileName, List<ByteArrayInputStream[]> conteudosZIP) throws Exception { response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName.replaceAll("u0020", "_").replaceAll(",", "_") + ".zip"); ServletOutputStream out = response.getOutputStream(); ZipOutputStream zout = new ZipOutputStream(out); Integer cont = 1; for(ByteArrayInputStream[] conteudoArray : conteudosZIP ) { try(PDDocument result = new PDDocument()){ PDFMergerUtility ut = new PDFMergerUtility(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); for(ByteArrayInputStream conteudo : conteudoArray) { try (PDDocument conteudoPDDocument = PDDocument.load(conteudo)){ ut.appendDocument(result, conteudoPDDocument); }finally { conteudo.close(); } } result.save(byteArrayOutputStream); ZipEntry ze = new ZipEntry(fileName + '_' + cont++ + ".pdf"); zout.putNextEntry(ze); zout.write(byteArrayOutputStream.toByteArray()); zout.closeEntry(); byteArrayOutputStream.close(); } } zout.close(); out.close(); FacesContext.getCurrentInstance().getRenderResponse(); FacesContext.getCurrentInstance().responseComplete(); }
Advertisement
Answer
tl;dr: don’t bother.
The message indicates that there is an /IDTree (which is a part of the PDF structure tree) in the /Name dictionary, and PDFBox removes that one because it doesn’t belong at this place. However here this is a bug in PDFBox, which didn’t check whether the IDTree existed at all.
If the /IDtree had really existed then it wouldn’t have been harmful, the only thing to do would have been to check what software has created that PDF and check whether it is current, and then try to contact the vendor and point to the PDF specification.
The bug has been fixed in PDFBOX-5100 and will be in 2.0.23.