0

all

I created a pdf template using libreoffice. I tried to fill chinese string into these field but only garbage in those fields. code like below:

            PdfFont kaiuFont = PdfFontFactory.createFont("c:/windows/fonts/kaiu.ttf", true);
            FileOutputStream output = new FileOutputStream("d:/download/202106.pdf");
            PdfDocument pdf = new PdfDocument(new PdfReader(template), new PdfWriter(output));
            PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);
            Map<String, PdfFormField> fields = form.getFormFields();
            fields.get("COMPANY_TITLE").setValue(<Chinese words>).setFontAndSize(kaiuFont, 18f);
            pdf.close();

What's wrong with those code?

Vincent Chen
  • 245
  • 2
  • 6
  • 13

1 Answers1

0

Please ignore this topic if your pdf is not generated by LibreOffice. I google d for a day and found this solution link and it works for me

libreoffice pdf issue

Vincent Chen
  • 245
  • 2
  • 6
  • 13
  • As that other stack overflow answer solved your issue, I closed your question as a duplicate thereof. – mkl Jun 07 '21 at 15:51