Cyrillic Letters in PDF Metadata Created by FO.NET
Has anyone succeeded in showing Cyrillic letters in the metadata of a PDF file that is generated by FO.NET? I tried the following code, but the metadata of the generated PDF displays only "Title: ??????":
FonetDriver driver = FonetDriver.Make();
PdfRendererOptions options = new PdfRendererOptions();
options.FontType = FontType.Embed;
options.Title = "Title: Услуги";
driver.Options = options;开发者_高级运维
driver.Render("Input_cyrillic.fo", "Output.pdf");
Here is the link to discussion on their forum. It seems to be that they don't support Unicode at all due to MapCharacter
method has this hardcoded:
ushort charIndex = CodePointMapping.GetMapping("WinAnsiEncoding").MapCharacter(c);
It also seems that the recent version has the same problem.
I do not know the details of FO.NET, but generally "text string" types in PDF can hold UTF-16 data (not UTF-8!) if you prepend the string with hex FEFF (the UTF byte order mark - BOM). In PHP it looks like this:
$pdfTitle = "\xfe\xff" . mb_convert_encoding($myTitleString, "UTF-16BE", "UTF-8");
This converts the title from UTF-8 to UTF-16 and prepends it with the BOM.
See the PDF docs for details: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
(chapter 7.9.2.2: "Text String Type")
精彩评论