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 <rea...@gmail.com>: > 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?