小编Joh*_*ons的帖子

如何使用 iTextSharp 从 PDF 中提取突出显示的文本?

根据以下帖子: 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)

.net pdf itext

5
推荐指数
1
解决办法
4041
查看次数

标签 统计

.net ×1

itext ×1

pdf ×1