Print Page | Close Window

Code page {936} GB2312_CHARSET

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2409
Printed Date: 01 May 24 at 8:56AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Code page {936} GB2312_CHARSET
Posted By: lenc
Subject: Code page {936} GB2312_CHARSET
Date Posted: 19 Sep 12 at 6:09PM
How to output Chinese (Simplified)?

With the following,
            int docID = qp.NewDocument();
            int ttfID = qp.AddTrueTypeFont("Arial Unicode MS [Italic]", 0);
            qp.SelectFont(ttfID);
            qp.SetTextSize(10.0);
            double pageTop = qp.GetPageBox(2, 1);
            double textHeight = qp.GetTextHeight();
            qp.DrawText(10, pageTop - (textHeight * 1) - 5, "... a day in the life");
            qp.DrawText(10, pageTop - (textHeight * 2) - 5, "... 生活中的一天");
            qp.SaveToFile(savePath + "test.pdf");
            qp.RemoveDocument(docID);

Text in PDF output:
   ... a day in the life
   ...

With the following,
            int docID = qp.NewDocument();
            int ttfID = qp.AddTrueTypeFont("Arial Unicode MS [Italic] {936}", 0);
            qp.SelectFont(ttfID);
            qp.SetTextSize(10.0);
            double pageTop = qp.GetPageBox(2, 1);
            double textHeight = qp.GetTextHeight();
            qp.DrawText(10, pageTop - (textHeight * 1) - 5, "... a day in the life");
            qp.DrawText(10, pageTop - (textHeight * 2) - 5, "... 生活中的一天");
            qp.SaveToFile(savePath + "test.pdf");
            qp.RemoveDocument(docID);

Text in PDF output (none): 

The text in the DrawText calls was copy/pasted from Google translate - English -> Chinese (Simplified).




Replies:
Posted By: AndrewC
Date Posted: 20 Sep 12 at 5:43AM

Which version of Quick PDF Library are you using ?  7.xx or 8.xx ?

In 8.xx we changed all the internal strings in the library to Unicode so it is not possible to send a DBCS encoded string to the 8.xx version of QPL.  For this reason we have recently deprecated the support of the following code pages from QPL 8.xx.  Adding CJK fonts works correctly in 8.xx if you use the QPL.AddTrueTypeSubsetFont

Andrew.
No longer supported in QPL 8.xx
=======================================
932 (Japanese Shift-JIS)
936 (Simplified Chinese GBK)
949 (Korean)
950 (Traditional Chinese Big5)
int ifontID2 = QP.AddTrueTypeSubsettedFont("MS Gothic", "こんにちは", 0);
if (QP.SelectFont(ifontID2) == 1)
{
  QP.DrawTextBox(30, QP.PageHeight() - 60, QP.GetTextWidth("こんにち    は"), QP.GetTextHeight(), "こんにちは", 0);
}


Posted By: lenc
Date Posted: 20 Sep 12 at 5:12PM
Hi Andrew,

Thanks for the clarification and quick response!
I'm using QPL 8.16.  I was a bit confused on the 'Add*SubSettedFont' functions usage.  Also, I did experiment a bit with the AddCJK function (even though reference states only 'Japanese "HeiseiKakuGo-W5" font is currently supported.)  When I loaded the generated PDF, Acrobat Reader informed me that I needed a font package to display the document and offered a link to the Adobe site download location.

lenc


Posted By: AndrewC
Date Posted: 21 Sep 12 at 2:07AM
NOTE : This forum doesn't display Unicode text very well and converts it to the jumble of characters in the previous messages.  These strings are meant to be human readable UNICODE strings with native CJK characters.
QP.AddTrueTypeSubsettedFont("MS Gothic", "こんにちは", 0);
We are slowly improving the Asian font support and more work will be done in 9.12 and 9.13. 9.11 now has support for rendering vertical Asian text from existing PDF files.

AddTrueTypeSubsettedFont works pretty well with most fonts these days and is a pretty reliable method that add Asian fonts to a PDF.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk