Enable Searching CJK fonts Programatically in Acrobat

For finding Asian characters in a pdf, normally a Ctrl-F is used. But in order to search a CJK font character, this doesn’t work.

In Acrobat, in order to search CJK characters, an additional setting is required to be done. This setting is to Ignore Asian characters width, which on being set, finds both half-width and full-width instances of the Asian language characters in the search text. Since the Japanese text inserted in the pdf would be double – byte, so this option needs to be set for the font in this pdf file being generated.

For this, the following change is needed in the code of after creating pdeFont the usual way:

sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); 

pdsysEncoding = PDSysEncodingCreateFromCMapName(pdeFontAttrs.encoding); 

pdeFont = PDEFontCreateFromSysFontAndEncoding(sysFont, pdsysEncoding,  ASAtomNull,  kPDEFontEncodeByGID | kPDEFontCreateToUnicode | kPDEFontCreateEmbedded 
 | kPDEFontWillSubset); 

PDEFontCreateWidthsNow(pdeFont, PDDocGetCosDoc(pdDoc));

Adobe logo

Sign in to your account