【问题标题】:Why i get the warning message "Removed /IDTree from /Names dictionary, doesn't belong there"?为什么我收到警告消息“从 /Names 字典中删除 /IDTree,不属于那里”?
【发布时间】:2021-02-11 21:38:27
【问题描述】:

我的代码正在运行,但我在控制台上收到此警告消息:

“从 /Names 字典中删除 /IDTree,不属于那里”

我刚刚搜索过它,但我没有找到任何东西。 有人知道导致此警告消息的原因吗?

我的代码:

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();
}

【问题讨论】:

  • 它是无害的,它是关于结构树的一个元素在错误的位置。但是,我查看了源代码,似乎即使那里没有 IDTree,警告也已完成。你能分享你的文件吗?
  • 固定在 issues.apache.org/jira/browse/PDFBOX-5100 中。如果可能的话,我还是想看看你的文件。
  • 嗨@TilmanHausherr,你可以在这里看到生成的文件。 drive.google.com/drive/folders/…
  • 谢谢,在错误的地方肯定没有 IDTree。我将在答案中总结我的 cmets。

标签: java pdfbox


【解决方案1】:

tl;dr:别打扰了。

该消息表明 /Name 字典中有一个 /IDTree(它是 PDF 结构树的一部分),并且 PDFBox 删除了那个,因为它不属于这个位置。然而,这是 PDFBox 中的一个错误,它根本没有检查 IDTree 是否存在。

如果 /IDtree 确实存在,那么它就不会有害,唯一要做的就是检查创建该 PDF 的软件并检查它是否是最新的,然后尝试联系供应商并指向 PDF 规范。

该错误已在PDFBOX-5100 中修复,并将在 2.0.23 中。

【讨论】:

    【解决方案2】:

    我在这里解决了这个警告问题,包括这一行:

    pmu.setDocumentMergeMode(PDFMergerUtility.DocumentMergeMode.OPTIMIZE_RESOURCES_MODE);
    

    pmu 是 PDFMergerUtility 的一个实例。

    顺便说一句,我使用的是 2.0.22 版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-19
      • 2019-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      • 1970-01-01
      • 2011-11-15
      相关资源
      最近更新 更多