pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Other languages in pdfmake

Open mpsbhat opened this issue 10 years ago • 39 comments

Is it possible to add other language support other than English (UTF-8) in pdfmake library? something like,

var dd = {
    content: [
        'ಕನ್ನಡ',              //Kannada
        'മലയാളം'       //Malayalam
    ]
}

mpsbhat avatar Apr 19 '16 04:04 mpsbhat

any news regarding this?

Gal-Brenner avatar Jan 31 '17 12:01 Gal-Brenner

I do not know these languages, but: LTR languages are supported (is need a font file that supports this language) RTL languages are not supported - pending issue https://github.com/bpampuch/pdfmake/issues/184

liborm85 avatar Jan 31 '17 12:01 liborm85

Can you give me an example of how to accept for example English an another one? Thanks!!!

Gal-Brenner avatar Jan 31 '17 12:01 Gal-Brenner

Manual of how to use custom font: https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side

liborm85 avatar Jan 31 '17 12:01 liborm85

Its working for few fonts but Lohith-kannada.ttf font not working and gives blank spaces. Also baraha-kannada.ttf font gives jumbled words.

Myself asked a question in Stack overflow here.

mpsbhat avatar Jan 31 '17 13:01 mpsbhat

@liborm85 , Myself tried with BARAHAKN.TTF, Nudi_05_k.ttf and lohit_kn.ttf Kannada fonts but each fonts giving jumbled sentences. Any workarounds to solve the issue?

mpsbhat avatar Mar 01 '17 04:03 mpsbhat

Kannada currently not supported (see test report). Implementation is required to fontkit library, which pdfmake uses.

liborm85 avatar May 07 '17 14:05 liborm85

@liborm85 Find the referenced issue above.

mpsbhat avatar May 21 '17 10:05 mpsbhat

@mpsbhat That's good. As soon as the new version of fontkit, it will work in pdfmake also.

liborm85 avatar May 21 '17 12:05 liborm85

@liborm85 , can we test it before release of new version of fontkit? Myself searching within the pdfmake files but didn't found the fontkit library call.

mpsbhat avatar May 21 '17 12:05 mpsbhat

@mpsbhat pdfmake calls only the pdfkit library. Calling the fontkit library is up to pdfkit library. Sorry, I don't know how to build fontkit from source code... :(

liborm85 avatar May 21 '17 13:05 liborm85

Ok @liborm85 Thank you for the info.

mpsbhat avatar May 21 '17 13:05 mpsbhat

Finally succeeded build :)

pdfmake + fontkit-dev with kannada/indic support: pdfmake.zip

I don't know if it is correct build, but it looks like it works. :) I try it with this font: https://github.com/devongovett/fontkit/blob/indic/test/data/NotoSans/NotoSansKannada-Regular.ttf

liborm85 avatar May 21 '17 14:05 liborm85

The above build gives blank pdf :( We included above pdfmake.js and created a new vfs-fonts.js using the mentioned font.

The base64data as follows: blob:null/096f394c-61cb-42d6-a3c1-58f9545286d5

mpsbhat avatar May 21 '17 16:05 mpsbhat

Here is my full test script: pdfmake-indic-test.zip This works for me, Try it.

liborm85 avatar May 21 '17 17:05 liborm85

Splendid...!!! screenshot from 2017-05-22 11 28 53

Thanks @liborm85 :)

mpsbhat avatar May 22 '17 03:05 mpsbhat

How can we use both English & Kannada fonts simultaneously?

mpsbhat avatar May 27 '17 04:05 mpsbhat

You create vfs_fonts.js file with multiple fonts. One for English and other for Kannada. See https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side

liborm85 avatar May 27 '17 05:05 liborm85

fontkit 1.7 has full support for indic scripts, including Kannada and 9 others. See https://github.com/devongovett/fontkit/pull/99 for details.

devongovett avatar May 30 '17 05:05 devongovett

New version pdfmake released.

liborm85 avatar May 30 '17 17:05 liborm85