Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
876 views
in Technique[技术] by (71.8m points)

php - Missing characters in filled pdf using PDFTk with encoding UTF-8

I'm trying to fill pdf documents using PDFTk. Script working fine, it fills inputs in form but I don't get special characters [polish charset: UTF-8 or ISO-8859-2].

Script: https://github.com/mikehaertl/php-pdftk

The weird thing is that generated pdf actually has polish characters when I click on field.

Before click:

enter image description here

After click on field:

enter image description here


Default encoding is set to UTF-8. The problem is that PDFTk can't use chars outside the standard ASCII with FDF form fill. It doesn't allow multi-byte characters.

What I did:

  1. Add fonts to pdf files (checked and files has font)
  2. Create fields in pdf files with default font (Arial)
  3. Change encoding in script (function fillForm) to ISO-8859-2
  4. Change data values encoding (iconv or mb_convert_encoding)
  5. Change functions encoding and data value encoding to ISO-8859-2
  6. Flatten pdf after filling the form
  7. Read all topics about this problem in stackoverflow, google

UPDATE (25.03.2016): Findout that pdf documents works fine on some computers. Some people have polish characters and other don't. All of us have right fonts (with polish charset). I used default Arial or Times New Roman. Fonts are also embed in that file.

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you need to run pdftk with need_appearances as an argument.

kudos to the guys from this issue on github.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...