c# - GemBox DocumentModel.Load() 无法读取 Pdf 文件
问题描述
目前我无法使用 GemBox 加载原始 pdf 文档。它给了我以下图像错误。我正在使用 Acrobat 9。
我也尝试过使用 8/16/2018 修复。任何建议将不胜感激。
我使用的基本代码是,
using GemBox.Document;
using System;
namespace Pdf2Text
{
class Program
{
[STAThread]
static void Main(string[] args)
{
ComponentInfo.SetLicense("My-License");
DocumentModel document = null;
document = DocumentModel.Load(@"E:\data\testing\HA021.pdf");
document.Save(@"E:\data\testing\HA021.docx");
}
}
}
解决方案
GemBox.Document 中 PDF 阅读器的当前实现仍处于测试阶段,无法处理此 PDF 功能,即“iref 流”,它是存储在流中的交叉引用表。
但是,GemBox.Pdf 可以处理交叉引用流,因此作为一种解决方法,您可以执行以下操作:
// Load PDF with GemBox.Pdf.
var pdfDocument = PdfDocument.Load("Sample.pdf");
pdfDocument.SaveOptions.CrossReferenceType = PdfCrossReferenceType.Table;
// Save PDF with GemBox.Pdf.
var pdfStream = new MemoryStream();
pdfDocument.Save(pdfStream);
// Load PDF with GemBox.Document.
var document = DocumentModel.Load(pdfStream, LoadOptions.PdfDefault);
最后关于 PDF 到 DOCX 的转换,GemBox.Document 的 PDF 阅读器目前用于从 PDF 文件中提取文本和表格,它不适合任何高保真要求。
推荐阅读
- javascript - 下载或导出 Chart.js 数据到 CSV
- delphi - 使用 GifImage 从 gif 中提取帧
- java - 如何禁用 Eclipse 模块信息弹出窗口?
- mapbox - 如何提取存储在 Mapbox 数据集中的 URL 并将其添加到弹出窗口的“单击”功能中?
- java - 如何通过网络运行 Jboss?
- python - “无法解压不可迭代的 int 对象”来自 OrderedDict
- java - Jersey 容器监听器中事件的集成测试
- css - 我可以使用什么 CSS 来隐藏此列表中的项目
- sql - 选择 2 行并切换值
- python - 如何优化我的函数以进行数值优化?