我对 Ubuntu 17.10 上 C++ 中的 PoDoFo lib 版本 0.9.5 有疑问。 我尝试通过扫描仪加载 PDF 扫描文档(对于非扫描文档,它可以正常工作),但是加载文档时出现问题。
pdf::Document::Document(const std::string &fname) {
try {
memDocument.Load(fname.c_str());
LTRACE << "created pdf::Document from file";
} catch (const PoDoFo::PdfError &error) {
LERROR << "Error while loading PDF document(" << fname << "): " << PoDoFo::PdfError::ErrorMessage(error.GetError());
}
}
memDocument
是 PoDoFo::PdfMemDocument
但我收到这个警告并且文档根本没有加载(仍然是 null ref of memDocument
) :
WARNING: There are more objects (15) in this XRef table than specified in the size key of the trailer directory (8)!
<</ID[<DC15F9B0B1D5684CB68315FC2D09425E<DC15F9B0B1D5684CB68315FC2D09425E>]/Info 7 0 R/Root 9 0 R/Size 8>>
有人遇到过同样的问题吗?或者有什么想法?
最佳答案
警告信息
WARNING: There are more objects (15) in this XRef table than specified in the size key of the trailer directory (8)!
<</ID[<DC15F9B0B1D5684CB68315FC2D09425E<DC15F9B0B1D5684CB68315FC2D09425E>]/Info 7 0 R/Root 9 0 R/Size 8>>
表示有问题的文档格式不正确:其对象交叉引用表包含 15 个条目,而文档尾部声明只有 8 个。
顺便说一句,警告中引用的预告片还包含损坏的 ID:第一个 ID 字符串末尾的“>”丢失。
因此,PDF 中似乎存在多个错误,导致 PoDoFo 根本无法加载它。
(Adobe Acrobat Reader 在加载时忽略或修复了 PFD 中的许多错误而没有提示,因此您可能没有意识到所有这些缺陷。)
关于c++ - 无法加载 PDF 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49328410/