Alvin Alvin - 1 year ago 155
Apache Configuration Question

highlight text using pdfbox when it's location in the pdf is known

Does pdfbox provide some utility to highlight the text when I have it's co-ordinates?

Bounds of the text is known.

I know there are other libraries that provide the same functionality like pdfclown etc. But does pdfbox provide something like that?

Answer Source

well i found this out. it is simple.

PDDocument doc = PDDocument.load(/*path to the file*/);
PDPage page = (PDPage)doc.getDocumentCatalog.getAllPages.get(i);
List annots = page.getAnnotations;
PDAnnotationTextMarkup markup = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.Su....);
markup.setRectangle(/*your PDRectangle*/);
markup.setQuads(/*float array of size eight with all the vertices of the PDRectangle in anticlockwise order*/);
annots.add(markup);*path to the output file*/);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download