pdf - How to know cmap compatible with font in Itext? -


i check font's encoding (the font's type opentype font), result below :

postscript name: hirakakupron-w3 available code pages: encoding[0] = 1252 latin 1 encoding[1] = 1251 cyrillic encoding[2] = 1253 greek encoding[3] = 932 jis/japan 

then, creat font code :

font f = new font(basefont.createfont("hirafont.otf", "identity-v", basefont.embedded)); 

except "identity-v" , "identity-h", can't use other cmaps such ("unijisx0213-utf32-h/v ..."). , in font see many glyphs displayed in rotation of 90 degrees. how map char in unicode char's glyph rotation in font?

example : '〔 ' (0x3014 12308 left tortoise shell bracket) map index 9265 in font

---------update code--------

pdfencodings.loadcmap("unijisx0213-utf32-v", pdfencodings.crlf_cid_newline); string temp = "a";  byte[] text = temp.getbytes("shift_jis"); string cid = pdfencodings.convertcmap("unijisx0213-utf32-v", text); basefont bf = basefont.createfont("hiraginofont.otf",basefont.identity_v, basefont.embedded); paragraph p = new paragraph(cid, new font(bf, 14)); 

i had dig first book find reference you're asking. long time ago, used distribute following jar: itext-asiancmaps.jar. jar not confused itext-asian.jar used cjk fonts.

it took me while find copy of jar. you'll find in old zip file: extrajars-2.1.zip

according first book (written in 2005-2006), can use jar encodings not supported cmaps in itext-asian.jar

it used this:

pdfencodings.loadcmap("gbk2k-h", pdfencodings.crlf_cid_newline); byte[] text = my_gb_encoded_text; string cid = pdfencodings.convertcmap("gbk2k-h", text); basefont bf = basefont.createfont("stsong-light",     basefont.identity_h, basefont.not_embedded); paragraph p = new paragraph(cid, new font(bf, 14)); document.add(p); 

as know basefont.identity_h , basefont.identity_v horizontal , vertical identity mappings 2-byte cids. pdfencodings class can convert string in specific encoding string 2-byte cids. in case, original string encoded in gb 18030-2000; needed convert string itext use identity_h encoding.

in first book, wrote: "i insert sample sake of completeness. in past 3 years, handful of people have posted questions this." time wrote second book (2009-2010), nobody asking functionality, dropped distributing jar cmaps , example didn't make second book.

i reviving old example in hope useful. tested once in 2005 or 2006, , worked then. can't guarantee still works today.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -