ITextSharp PDF Reading high level text (annotation highlighting) using C #
I am developing a C # winform application that converts pdf content to text. All required content is retrieved except for the content found in the selected pdf text. Please help to get a working sample to extract the selected text to pdf. I am using iTextSharp.dll in a project
+1
Binod
source
to share
1 answer
Assuming you are talking about comments. Try the following:
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
}
}
}
This is written from memory (I'm a Java developer, not a C # developer).
+1
Bruno lowagie
source
to share