iTextSharp PDF使用C#读取高亮度文本(突出显示注释) [英] iTextSharp PDF Reading highlighed text (highlight annotations) using C#

查看:403
本文介绍了iTextSharp PDF使用C#读取高亮度文本(突出显示注释)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个C#winform应用程序,它将pdf内容转换为文本。除了在pdf的突出显示文本中找到的内容之外,提取所有必需的内容。
请帮助获取工作样本以提取pdf中的突出显示文本。
我在项目中使用iTextSharp.dll

I am developing a C# winform application that converts the pdf contents to text. All the required contents are extracted except the content found in highlighted text of the pdf. Please help to get the working sample to extract the highlighted text found in pdf. I am using the iTextSharp.dll in the project

推荐答案

假设你在谈论评论。请试试这个:

Assuming that you're talking about Comments. Please try this:

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#开发人员)。

This is written from memory (I'm a Java developer, not a C# developer).

这篇关于iTextSharp PDF使用C#读取高亮度文本(突出显示注释)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆