Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Chinese Characters and Subsetted fonts

Question

I'm trying to embed chinese characters into a pdf file. The chinese is encoded by windows presumably with UTF16. My current code trys the following

int font = qp.AddSubsettedFont("Arial", 6, ChineseUnicodeString);
qp.SelectFont(font);
String sub = qp.GetSubsetString(ChineseUnicodeString);
double height = qp.GetWrappedTextHeight(width, "W");
int ret = qp.DrawTextBox(x, y, width, height,sub, 1);

Now I get a corrupted heap on the GetSubsetString call. The pdf file contains no chinese strings at all (including garbage) and height above is set to 0.

The ChineseUnicodeString looks like 联系电话

Answer

We ran a few tests on our end and were able to successfully draw your Chinese text string to a text object in a PDF. I've included the JScript code that we used for this below. If you use the same sequence of function calls as below it should work correctly. If this still won't work for you please contact us directly with your full source code and we'll examine the issue further.

// Our string of unicode text goes here

drawstr = "联系电话";

// Add a subset font for the text string

QP.AddSubsettedFont("Arial", 6, drawstr);

// Remap the string to ensure that the correct character 
// codes are used.

substr = QP.GetSubsetString(drawstr);

// Draw the Unicode text onto the page

QP.DrawText(100, 600, substr);

// Save the new file to disk

QP.SaveToFile("Unicode.pdf");

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum