Q:

Printing the ≤ symbol on a PDF file using JagPDF libraries

I am creating a PDF file using JagPDF and I am trying to print the ≤ symbol like this:
pdf::Document doc(pdf::create_file("report.pdf"));
doc.page_start(792,612);   
pdf::Font font = doc.font_load("standard; name=Times-Roman; size=12");
doc.page().canvas().text_font(font);
doc.page().canvas().color("f", 0);
doc.page().canvas().text_rendering_mode("f");
doc.page().canvas().text(100, 300, "PEP ≤ 90");
doc.page_end();
doc.finalize();

that prints out
PEP ? 90

I tried reading the documentation and they say something about Unicode but couldn't understand how they work, it must be easy and just something I am missing. Can anybody help me?

A:

I'm not familiar with JagPDF but "PEP ≤ 90" should work fine, provided that you saved the source code as UTF-8 and the library also expects an UTF-8 string. You can also use "PEP \u2264 90" with \uXXXX is the escape sequence for the code point U+XXXX, but that's obviously less readable
According to the documentation you can set the encoding and output the text with the below snippet

font = doc.font_load("file=DejaVuSans.ttf; size=14; enc=utf-8")
canvas.text_font(font)
text = unicode_text.encode('utf8')
canvas.text(50, 780, text)

http://www.jagpdf.org/doc/jagpdf/usersguide/text.htm

You also need to use a TrueType or OpenType font because there's a note under Type 1 font in the same page

Even though JagPDF allows to change the font built-in encoding to UTF-8, we are in practice limited to the Latin alphabet, because of the character set used by the standard fonts.

If you use C++11 and up (which you should) then you can force the encoding as UTF-8 with either of the below
u8"PEP ≤ 90"
u8"PEP \U00002264 90"
u8"PEP \u2264 90"

