PHP passthru with pdftk not supporting unicode characters

165 views Asked by At

I am trying to fill a pdf template with Chinese and Japanese Language. TCPDF is the library used and for filling data to pdf used forge_fdf. Following is the code used

passthru("pdftk $abs_pdf_path fill_form $fdf_fn output $certFileName owner_pw foopass allow DegradedPrinting flatten");

$abs_pdf_path is path of my template file. $fdf_fn is a temporary file holding data as follows which is used to fill the template

%FDF-1.2
%����
1 0 obj
<<
/FDF << /Fields [ << /T (input_name) /V (Chinese : 这是一个测试文本) /ClrF 2 /ClrFf 1 >>
<< /T (input_date) /V (2021-08-12 00:00:00) /ClrF 2 /ClrFf 1 >>
<< /T (certificate_number) /V (IMP21JKX5L8K) /ClrF 2 /ClrFf 1 >>
<< /T (certid) /V (IMP21JKX5L8K) /ClrF 2 /ClrFf 1 >>
<< /T (timestamp) /V (2021-08-18 12:14:49) /ClrF 2 /ClrFf 1 >>
]
>>
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF

$certFileName is the pdf file that need to output the result.

But when the pdf is generated the Unicode characters are printing like this "Chinese : 这是一个测试文本"

How to resolve this ?

0

There are 0 answers