I'm inserting bookmarks to existing PDF and have some problem with accented "c". There is the example (charset used in the example is UTF-8):
$name = "Ruční nářadí";
$name = chr(254).chr(255).iconv('UTF-8', 'UTF-16BE', str_replace(array('(',')','/'),array('\\(','\\)','\\/'),$name));
$fh = fopen('pdfmark.txt', 'w');
fputs($fh, "[/Title ({$name}) /Page 1 /OUT pdfmark
");
fclose($fh);
$command = "gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf final.pdf pdfmark.txt; mv out.pdf final.pdf";
exec($command);
The problem is that accented č
appears in bookmark of final PDF as Ċ
(uppercase letter with different accent). I tried other accented characters used in my language (Czech) and except of this one everything is ok.
Thanks for any clues to solve this issue.
EDIT (2013-02-01):
Version of GhostScript used is 9.06 (2012-08-08). I'm using Adobe Reader 11.0.1 to view the resulting PDF file.
I'm still thinking about it...Does it have to be encoding specified in PDF in some way? Because the source PDF is out of my control and I know quite nothing about it. If it is the case, is there any way to use GS or pdfmark to do so? I thought that if the encoding of the bookmarks is Unicode so it realy doesn't matter, but maybe I'm wrong.
EDIT (2013-02-05):
There seems to be bug in GS's pdfwrite or Acrobat, more info in GS's bug tracking. I will write solution info here, after it will be resolved.