根据以下帖子: iTextSharp PDF 使用 C# 读取突出显示的文本(突出显示注释)
这段代码:
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
}
}
}
Run Code Online (Sandbox Code Playgroud)
正在努力提取 PDF 注释。但是为什么以下相同的代码无法突出显示(特别是 PdfName.HIGHLIGHT 不起作用):
for (int i = pageFrom; i <= pageTo; i++) {
PdfDictionary page = reader.GetPageN(i);
PdfArray annots = page.GetAsArray(iTextSharp.text.pdf.PdfName.HIGHLIGHT);
if (annots!=null)
foreach (PdfObject annot …Run Code Online (Sandbox Code Playgroud)