我正在开发一个将 pdf 内容转换为文本的 C# winform 应用程序。除了在 pdf 的突出显示文本中找到的内容外,所有必需的内容都被提取出来。请帮助获取工作示例以提取 pdf 中的突出显示文本。我在项目中使用 iTextSharp.dll
问问题
1521 次
1 回答
1
假设您在谈论评论。请试试这个:
for (int i = pageFrom; i <= pageTo; i++) {
PdfDictionary page = reader.GetPageN(i);
PdfArray annots = page.GetAsArray(iTextSharp.text.pdf.PdfName.ANNOTS);
if (annots!=null)
foreach (PdfObject annot in annots.ArrayList) {
PdfDictionary annotation = (PdfDictionary)PdfReader.GetPdfObject(annot);
PdfString contents = annotation.GetAsString(PdfName.CONTENTS);
// now use the String value of contents
}
}
}
这是从内存中编写的(我是 Java 开发人员,而不是 C# 开发人员)。
于 2014-04-28T13:53:17.203 回答