You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Congwei Ni <co...@thoughtworks.com> on 2024/01/05 07:41:42 UTC

Inquiry on Filling Chinese Characters in AcroForm with PDFBox 3.0.1

Hi Apache PDFBox Team,

I am currently working with PDFBox 3.0.1 for filling AcroForm fields in my
PDF files, with Chinese characters. In my attempts, I've loaded the
SimSun.ttf Chinese font into the file and set embed subset to false. While
this approach successfully fills the Chinese characters, the resultant PDF
file size is significantly large, which does not meet my requirements.

When I set embed subset to true, the file size is reduced, and the PDF
displays correctly on my Mac. However, on Windows, the embedded Chinese
characters in the same file appear as garbled text. Notably, the same
SimSun.ttf font is installed on both systems.

I am seeking advice on how to meet the following requirements:

1. Correctly embed Chinese characters into AcroForm fields, ensuring they
display accurately across most systems without any encoding issues.

2. Keep the final PDF file size under 500KB.


To illustrate my issue, I have attached the following items to this google
drive:

https://drive.google.com/drive/folders/1vUiKt_Z1z7CwgIaL73Jki_FmAZIWOw1c?usp=drive_link

1. A PDF file generated with embed subset set to true.

2. A PDF file generated with embed subset set to false.

3. The source code I am using for embedding the font and filling the form.

4. SimSun.ttf I am using

Could you please provide guidance or suggest alternative methods to achieve
these objectives? Any sample code would be greatly appreciated.


Thank you for your assistance.

Best regards,

Congwei

Re: Inquiry on Filling Chinese Characters in AcroForm with PDFBox 3.0.1

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

I only remember that we always advise to never embed font subsets in 
AcroForm fields. Your subsetted file doesn't have the actual subset fonts.

Does this effect also happen when you don't flatten? And if you save 
first, then reload and flatten?

Tilman

On 05.01.2024 08:41, Congwei Ni wrote:
>
> Hi Apache PDFBox Team,
>
> I am currently working with PDFBox 3.0.1 for filling AcroForm fields 
> in my PDF files, with Chinese characters. In my attempts, I've loaded 
> the SimSun.ttf Chinese font into the file and set embed subset to 
> false. While this approach successfully fills the Chinese characters, 
> the resultant PDF file size is significantly large, which does not 
> meet my requirements.
>
> When I set embed subset to true, the file size is reduced, and the PDF 
> displays correctly on my Mac. However, on Windows, the embedded 
> Chinese characters in the same file appear as garbled text. Notably, 
> the same SimSun.ttf font is installed on both systems.
>
> I am seeking advice on how to meet the following requirements:
>
> 1. Correctly embed Chinese characters into AcroForm fields, ensuring 
> they display accurately across most systems without any encoding issues.
>
> 2. Keep the final PDF file size under 500KB.
>
>
> To illustrate my issue, I have attached the following items to this 
> google drive:
>
> https://drive.google.com/drive/folders/1vUiKt_Z1z7CwgIaL73Jki_FmAZIWOw1c?usp=drive_link
>
> 1. A PDF file generated with embed subset set to true.
>
> 2. A PDF file generated with embed subset set to false.
>
> 3. The source code I am using for embedding the font and filling the form.
>
> 4. SimSun.ttf I am using
>
> Could you please provide guidance or suggest alternative methods to 
> achieve these objectives? Any sample code would be greatly appreciated.
>
>
> Thank you for your assistance.
>
> Best regards,
>
> Congwei
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail:users-help@pdfbox.apache.org