That doesn't work, it turns out. Only the test PDFs were working. Trying
to overlay "real" PDFs result in an error that Cos Arrays are not supported.
So I then tried to use PDF annotations instead. This seemed to work
fine. However, when someone tried to print the PDF, annotated text was
not highlighted at all, even though it looks just fine on screen!
So I'm out of ideas. It would appear that PDFBox is indeed incapable of
highlighting text?
On 17/02/14 17:18, Nikos Chantziaras wrote:
I've come up with a good way to insert color-filled rectangles through
the use of Overlay (so that they are rendered behind the text instead of
the front of it.)
On 17/02/14 13:52, Maruan Sahyoun wrote:
[...]
If you would like to make the highlight part of the PDF you could
create an annotation or draw a rectangle behind the text.
Steps would be a. find the text b. get the coordinates of the text c.
create an annotation or a rectangle around the coordinates
You could also use the information in the highlight xml file to get
the coordinates for the annotation/rectangle
Am 17.02.2014 um 12:09 schrieb Nikos Chantziaras <rea...@gmail.com>:
It is not apparent how to save a PDF after I highlight some text in
it. For example:
PDDocument doc = PDDocument.load("source.pdf"); PDFHighlighter hl =
new PDFHighlighter(); java.io.FileWriter xml = new
java.io.FileWriter("tmp.xml"); hl.generateXMLHighlight(doc, "450",
xml);
How do I now save source.pdf (or a copy of it, if overwriting is
not possible) with the text highlighted?