Hi,
I would like to use the following:
public static void main(String[] args) throws UnsupportedEncodingException, DecoderException {
// open document
Document pdfDocument = new Document(inputFile);
Page pdfPage = pdfDocument.getPages().get_Item(1);
TextFragment textFragment = createTextFragment(pdfPage);
pdfPage.getParagraphs().add(createFloatingBox(textFragment));
// save updated PDF file
pdfDocument.save(outputFile);
}
private static TextFragment createTextFragment(Page pdfPage) {
String text = "This is some custom-text above the title.\n" +
"10.11.2020 15:30\n" +
"Fachidiot für traumatologies";
TextFragment textFragment = new TextFragment(text);
return textFragment;
}
private static FloatingBox createFloatingBox(TextFragment textFragment) {
FloatingBox box = new FloatingBox();
box.setTop(Double.parseDouble("2") * 72);
box.setLeft(Double.parseDouble("2") * 72);
box.setHeight(Double.parseDouble("1") * 72);
box.setWidth(Double.parseDouble("4") * 72);
box.setHorizontalAlignment(HorizontalAlignment.Left);
box.setVerticalAlignment(VerticalAlignment.Top);
textFragment.setMargin(new MarginInfo(0, 0, 0, 0));
box.getParagraphs().add(textFragment);
return box;
}
When the text has an ‘ü’, the text is not shown at all on a PDF Page. If I change the ‘ü’ to ‘ue’, so the text is shown correctly? What should I do for having support to special characters?
I use Aspose.pdf for Java Version 20.9
best regards,
Igor