Using PDF for Java version 20.7 when stamping text that contains 4 byte characters in it regardless of the system’s encoding or font used it shows as boxes instead of the character.
Code:
public static void main(String[] args) {
String inPdf = “test.pdf”;
String outPdf = “test_after.pdf”;
FormattedText formattedText = new FormattedText();
formattedText.addNewLineText(“𠝹𠝹𠱓𠱓𠱸𓆣:adult:”);
TextStamp textStamp = new TextStamp(formattedText);
textStamp.setHorizontalAlignment(HorizontalAlignment.Center);
textStamp.setVerticalAlignment(VerticalAlignment.Top);Document document = new Document(inPdf); for (Page page : document.getPages()) { page.addStamp(textStamp); } document.save(outPdf);
}
Test file(but any pdf should work): test.pdf (7.6 KB)
Example: image.png (6.9 KB)
Should note I tried this without using FormattedText as well to see if that was the problem and just using TextStamp with a string value directly still has the same problem.
TextStamp textStamp = new TextStamp(“𠝹𠝹𠱓𠱓𠱸𓆣:adult:”);