Q: I need to open a PDF and add anmotations to specific text values
related to List of Tables and List of Appendices
Is there a Text Search function or do I need to iterate through all
pages (as per “TextExtractTest.cs”):
Open document
Iterate through all pages
Set reader for current page
Loop through every page element
If Element.Type.e_text:
- GetBox() to get the coordinates
- GetTextString() to get the actual text
If there is a match the text to annotate
Create annotation
A: Yes, you need to use ElementReader to extract text run ‘elements’
and their positioning information. Given the positioning information,
you could create a hyperlink (a type of annotation) as follows:
// Create a link action (in C#) -----------
Obj action = Obj.CreateDict(); link3.Put(“A”, action);
action.Put(“S”, Obj.CreateName(“URI”));
action.Put(“URI”, Obj.CreateString(“http://www.pdftron.com”));
Annot link = Annot.CreateLink(doc, new Rect(85, 458, 503, 502),
action);
page.AnnotPushBack(link);
//----------------------------------------
Nic