Troubleshooting

文件未能关闭 内存泄漏

Document 工具 AutoCloseable.总是使用试用资源的区块:

try (Document doc = new Document("input.pdf")) {
    // operations
} // doc.close() called automatically

具有大文件的OutOfMemory错误

在大型文档中启用磁盘缓冲功能 PdfFileEditor:

PdfFileEditor editor = new PdfFileEditor();
editor.setUseDiskBuffer(true);
editor.concatenate(inputFiles, "output.pdf");

文件安全:错误密码

decryptFile(password) 报价情况 false 如果输入的密码不正确. 总是检查返回值并处理故障情况:

try (PdfFileSecurity security = new PdfFileSecurity()) {
    security.setInputFile("encrypted.pdf");
    security.setOutputFile("decrypted.pdf");
    boolean ok = security.decryptFile("ownerPassword");
    if (!ok) {
        System.err.println("Decryption failed — verify the owner password.");
    }
}

文件编辑器:无参数

PdfFileEditor.resizeContents() 无声地忽视空证,而不是投. 如果输出文档在后面出现未变,则: resizeContents(),核实该数据是否符合 ContentsResizeParameters 参数不是零,并且百分比值的总和是: 完全是100个.

错误的密钥长度

AES需要的密钥为16字节,24字段或32字符 (128,192字点或256位).通过错误长度的关键导致Java加密提供商的例外.

没有注释

如果添加注释,但在浏览器中没有出现,请检查:

  1. 标注矩形在页面的内. MediaBox
  2. page.getAnnotations().add(annotation) 在配置所有属性后被调用了
  3. 在添加注释后保存了文件.

See Also

 中文