Unicode

DynamicPDF Generator for COM/ActiveX (v4) Forum

 Dec 12 2008 8:56 AM
Hi,

I've recently come across an irregularity concerning unicode characters. I'm displaying a database field, which is ntext, that can contain unicode (i.e. &# 8211; an en dash or &# 8217; a right single quotation mark). These characters are inputted by our clients. While these characters display correctly in html, they do not display in the pdf's textarea. It literally displays the unicode as "&# 8211;", without the space.

Have you any idea why this occurs or how I could prevent it?

Thank you.

Jim.
 Dec 12 2008 10:55 AM
Posted by a ceTe Software moderator
Hello Jim,

The values what you are passing are the decimal values of the symbol single quote. You can use this in XML, and HTML texts without any problem. You will have to use the hexadecimal values when adding to a PDF document. Following is a sample code for this.

    Document doc = new Document();
    Page page = new Page();
        
    Label label1 = new Label("\u2018", 10, 10, 10, 20);
    Label label2 = new Label("\u00AE registered trade mark", 14, 10, 150, 20);
    Label label3 = new Label("\u2019", 145, 10, 10, 20);

    page.Elements.Add(label1);
    page.Elements.Add(label2);
    page.Elements.Add(label3);

    doc.Pages.Add(page);
    doc.Draw(@"C:\Temp\test.pdf");

"\u2018" and "\u2019" are the unicode values to display the single quotes. We have found some information by searching in google which will show the hexavalues and decimal values for these symbols. You can refer to this at  http://www.cs.sfu.ca/~ggbaker/reference/characters/#single.

Thanks,
ceTe Software Support Team.
 Dec 12 2008 12:29 PM
Posted by a ceTe Software moderator
Hello Jim,

You can also use the decimal values to add the symbols to the PDF. You will have to use the ChrW function from the Microsoft.VisualBasic.Strings class. Following is a sample code for this.

 string symbol = Microsoft.VisualBasic.Strings.ChrW(8216).ToString();
 Label label1 = new Label(symbol, 10, 10, 10, 20);

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:22 AM.