pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

How to handle localization issues in PDFMake?

Open suhasbhattu opened this issue 7 years ago • 3 comments

I am trying to generate a PDF using PDFMake which contains characters other than English also. (like Chinese, Japanese, Korean, etc.) Therefore, I decided to use the Arial Unicode MS font (size: 22MB) to display all characters in the PDF. I added the font in \examples\fonts\ directory and I have also added the base64 for the font in \build\vfs_fonts.js. But as the font size is large, PDFMake takes too much time for loading. Is there any efficient way to handle such case where localization support is required? As I am sharing the code.

pdfMake.fonts = {
    ArialUnicode: {
         normal: "arialuni.ttf"
    }
};

var docDefinition = {
	content: [
		'First paragraph',
		'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
	],
        defaultStyle: {
            font: "ArialUnicode"
       }	
};

pdfMake.createPdf(docDefinition).download("test.pdf");

For this simple example, PDFMake takes 10-15 seconds to load the library. Is there any way localization cases can be handled and performance remains to be consistent? Thanks in advance.

suhasbhattu avatar Apr 08 '19 10:04 suhasbhattu

I too had same type of problem. What I did to improve load time was changing the ttf to woff format as it reduces the size , and pdfmake works with them. Also try to choose fonts which are already smaller in size. You can also edit the fonts and remove the glyphs that are not useful.

srajan96 avatar Apr 10 '19 06:04 srajan96

Thanks @srajan96 for this. Can you please suggest some way of editing the fonts and removing the glyphs. Is some tool available for this?

suhasbhattu avatar Apr 10 '19 09:04 suhasbhattu

You may try this Font Squirrel link, if it allows you to do it 😉. It blocked my font 😢 .

srajan96 avatar Apr 10 '19 11:04 srajan96