c# - Change font encoding in itextsharp -


my main purpose displaying chinese font in pdf.

the code have modify

backgroundcolor = fonthelper.getpdfcolor(0, 0, 255), fontcolor = fonthelper.getpdfcolor(0, 255, 0), fontstyle = fontstyle.normal, fontencoding = fontencodings.cp1252, fontname = fontnames.times_roman 

it seems issue fontencodings.cp1252 or/and fontnames.times_roman, , read related post think, can't find simple solution.

i don't know enough code i'm working on, modify less possible. saw solution fontselector or else , it's different have in code, , hos integrate code. pretty solution old, , potentially not date.

so, exist simple way modify font ?

this minimal viable code-sample think of shows how change font piece of text.

static void main(string[] args) {     // setup    pdfwriter writer = new pdfwriter(@"c:\users\joris schellekens\downloads\output.pdf");    pdfdocument pdfdocument = new pdfdocument(writer);    document doc = new document(pdfdocument);     // font    pdffont font = pdffontfactory.createfont(@"c:\windows\fonts\comicbd.ttf");     // paragraph    paragraph para = new paragraph("lorem ipsum dolor sit amet");    para.setfont(font);     // add    doc.add(para);     // close    doc.flush();    doc.close(); } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -