Ah, thanks for explaining it. I wasn't aware that XML files are supposed
to be used by Adobe's software.
Do you happen to know why on Linux I can't compile Java source that uses
pdfbox?
$ javac -classpath /usr/share/pdfbox/lib/pdfbox.jar pdf.java
pdf.java:1: error: package org.apache.pdfbox does not exist
$ javac -version
javac 1.7.0_51
On 17/02/14 13:52, Maruan Sahyoun wrote:
Hi,
the XML file is meant to be passed to Adobe Acrobat or Adobe Reader which will
take the information and highlight the text accordingly. It’s not something to
be saved in the PDF directly.
A sample url would look like http://server/myPDF.pdf#xml=myHighlight.xml
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
BR
Maruan Sahyoun
Am 17.02.2014 um 12:09 schrieb Nikos Chantziaras <[email protected]>:
Hello.
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?