As per folowing post: iTextSharp PDF Reading highlighed text (highlight annotations) using C#
this code:
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
}
}
}
is working to extract PDF annotations. But why the same following code is not working for highlight (specifically PdfName.HIGHLIGHT is not working) :
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 in annots.ArrayList) {
PdfDictionary annotation = (PdfDictionary)PdfReader.GetPdfObject(annot);
PdfString contents = annotation.GetAsString(PdfName.CONTENTS);
// now use the String value of contents
}
}
}