static void strings(String[] args)
{
Document doc = jagpdf.create_file(args[0] + "/jagpdf_doc_java_strings.pdf");
doc.page_start(597.6, 848.68);
Canvas canvas = doc.page().canvas();
//[java_example_string
/*` An example should make it clear. Let's load a standard ISO-8859-2
encoded font. */
Font helv = doc.font_load("standard; enc=iso-8859-2; name=Helvetica; size=24");
canvas.text_font(helv);
/*` One of the languages representable by this encoding is Czech. We can
pass a Unicode string ['úplnÄ›k] (full moon). [lib] converts the string
to ISO-8859-2 and it is shown correctly. */
String full_moon_cze = "\u00fapln\u011bk";
canvas.text(50, 800, full_moon_cze); // ok
/*` If we pass Swedish ['fullmåne], letter ['å] will not be shown
because ISO-8859-2 does not represent such character. We should have
used ISO-8859-1 encoded font instead. */
String full_moon_swe = "fullm\u00e5ne";
canvas.text(50, 760, full_moon_swe); // wrong
/*` Let's load a Unicode encoded TrueType font. */
//<-
/* //->
Font dejavu = doc.font_load("enc=utf-8; file=DejaVuSans.ttf; size=24");
//<- */
String res_dir = testlib.getResourcesDir();
String dejavu_file = res_dir + "/fonts/DejaVuSans.ttf";
Font dejavu = doc.font_load("enc=utf-8; file=" + dejavu_file + "; size=24");
//->
canvas.text_font(dejavu);
/*` Now we can mix Czech and Swedish and it will be shown correctly as
[lib] converts the strings to UTF-8.*/
canvas.text(50, 720, full_moon_swe);
canvas.text(50, 680, full_moon_cze);
//]
doc.page_end();
doc.finalize_doc();
}