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

Adding PRC unicode strings into Quick PDF

Question

I need to be able to generate PDF's files with Simplified Chinese characters. I have tried a couple of things but cannot get it to work.

For example:

String Font = "Arial [Bold] {936}";
int id = qp.AddTrueTypeFont(font, 936);
qp.SelectFont(id);
qp.DrawText(100, 100, ChineseText);

But all I get is garbage.

What is the correct way of doing this?

Answer

Quick PDF Library currently only supports 8-bit fonts.

There is support for 16-bit CJK fonts, but only the Japanese font "HeiseiKakuGo-W5" has been implemented.

QPL's font subsetting functionality can be used to draw Chinese text though.

The first step is to call the AddSubsettedFont function giving a font name, specifying the character set and a list of characters to subset.

Up to 255 characters can be placed into each subsetted font.

Then the usual text drawing functions can be used - but the Unicode characters must first be mapped to 8-bit character codes using the GetSubsetString function.

Here's an example written in C#:

// Subset a few characters from the Arial font
// using the CHINESEBIG5_CHARSET character set
qp.AddSubsettedFont("Arial", 7, "你好世界");

// Convert the Unicode text to 8-bit characters and draw them onto the page
qp.DrawText(100, 500, qp.GetSubsetString("你好世界"));

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