php-pdftk: Missing characters
Hello i am using part of your code. FfdfFile class with following code(only the part with characters):
if ($directory === null) {
$directory = sys_get_temp_dir();
}
$filename = $filename;
$fields = '';
foreach ($data as $key => $value) {
$utf16Value = mb_convert_encoding($value,'UTF-16BE', $encoding);
// Escape parenthesis
$utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
$fields .= "<</T($key)/V(" . chr(0xFE) . chr(0xFF) . $utf16Value . ")>>\n";
}
Problem is that some characters are missing like “čćđ”, on the other hand there are “šž”, which is nice but i need them all… I have tried few things but i can’t quite get more characters working. If i open created .fdf file in notepad i can see an empty space where “č” should be. I am using .fdf file to fill out pdf and at the places with missing characters there is a blank spot…
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 49 (18 by maintainers)
Hey, found some relevant stuff https://www.drupal.org/node/1016482 It appears that if I put “need_appearances drop_xfa” instead of “flatten”, it shows my missing unicode characters (čČćĆđĐ). Gotta find a way to flatten it now >.< Without flattening it, it appears correctly and even upon download it appears fine in adobe, but I need to pass file on to some other web api and mentioned characters are missing again there… Any idea how to flatten it?
I modified Command class to use this MCPDF and it works!
Any idea how to flatten it withou losing appearance? Flat document is essential to me. Any working alternative to pdftk would work too…
@Niproblema 👍 That makes perfect sense! Actually “appearance” in PDF parlance means, that the PDF viewer will do whatever is neccessary to display any obscure characters that are contained in a field value. Whereas if you flatten the PDF, it means, that all the font data for non standard characters must be included in the PDF file itself (which pdftk doesn’t do). At least that’s how I understand it.
So this at least makes it work with unflattened files.
need_appearanceis only available from pdftk 2.* . And since the class now is written around pdftk 1.* , this option is not yet available. As soon as I find a way to install pdftk 2.* on my Ubuntu 12.04 box, I will create a new version and add this missing option.