Issue regarding Unicode in pdf -


i have written code, generates simple pdf documents. couldn't able render unicode characters pdf. suggestions appreciated.

suppose have following strings in unicode:

public static final string czech =         "podivn\u00fd p\u0159\u00edpad dr. jekylla pana hyda"; public static final string russian =         "\u0421\u0442\u0440\u0430\u043d\u043d\u0430\u044f "         + "\u0438\u0441\u0442\u043e\u0440\u0438\u044f "         + "\u0434\u043e\u043a\u0442\u043e\u0440\u0430 "         + "\u0414\u0436\u0435\u043a\u0438\u043b\u0430 \u0438 "         + "\u043c\u0438\u0441\u0442\u0435\u0440\u0430 "         + "\u0425\u0430\u0439\u0434\u0430"; public static final string korean =         "\ud558\uc774\ub4dc, \uc9c0\ud0ac, \ub098"; 

then need find font programs able render characters. instance:

public static final string font = "src/main/resources/fonts/freesans.ttf"; public static final string hcrbatang = "src/main/resources/fonts/hanbatang.ttf"; 

freesans free font shipped linux; supports lot of languages, not all. instance: korean isn't supported, hence use han batang.

we use these font programs create pdffont objects, , use objects in paragraph objects:

pdffont freeunicode =     pdffontfactory.createfont(font, pdfencodings.identity_h, true); document.add(new paragraph().setfont(freeunicode)     .add(czech).add(" robert louis stevenson")); document.add(new paragraph().setfont(freeunicode)     .add(russian).add(" robert louis stevenson")); pdffont fontunicode =     pdffontfactory.createfont(hcrbatang, pdfencodings.identity_h, true); document.add(new paragraph().setfont(fontunicode)     .add(korean).add(" robert louis stevenson")); 

the result shown in following screen shot:

enter image description here

as can see, rendering unicode simple when using itext 7. example taken chapter 1 of itext 7: building blocks tutorial.

if not information looking for, fix question , explain tool used instead of itext, , programming language.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -