I have a PDF document with a text field and I want to enter an euro symbol (€)
with a program, but I'll get a strange character (¬). This is the code:
import java.io.*;
import org.apache.pdfbox.pdmodel.*;
import org.apache.pdfbox.pdmodel.interactive.form.*;
public class PdfTest {
public static void main(final String args[]) throws Exception {
// load test document
PDDocument pdfDocument = PDDocument.load(new File("test.pdf"));
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
// get test2 field and set Euro
PDFieldTreeNode test2 = acroForm.getField("test2");
test2.setValue("€");
// save as new document
pdfDocument.save("test2.pdf");
pdfDocument.close();
}
}
See http://www.frank-buss.de/tmp/pdfTest.zip for the test.pdf and the generated
test2.pdf. I'm using the latest snapshot
(pdfbox-app-2.0.0-20150418.010411-1224.jar), but the same problem was in a
snapshot from January, too. How can I solve the problem? I can try to fix it in
the library, too, if someone can give me a hint where to search.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]