Follow

Some particularities with using fonts and PDF export

Sometimes you get squares in the PDF documents that you got with our product.
You have got the issue because browsers can replace missed fonts with available fonts.
It's even possible to set a sequence of fonts that browser should look for.
In PDF format it works completely different because the PDF is fixed layout format. That's why it is so popular.
It guarantees that you will get exactly the same result as you need. On any machine and on any printer.
A PDF reader doesn't look for any available font. It shows exactly what you have specified.
And if there is no necessary font or symbol the square is shown instead of the missed font.

To avoid this issue you should be sure that you use the fonts that are available on all machines where the PDF file will be opened.
If you are not sure, you could add the used fonts to the PDF file. It will be significantly larger but this guaranty that you get the expected result.
There is a font compression algorithm that reduces size of the PDF file.

But there is one more issue. JavaScript have no access to the local files from the browser. So the whole font file should be uploaded. You could use next code to load the necessary fonts.

Stimulsoft.Base.StiFontCollection.addOpentypeFontFile("data/arial.ttf", "Arial");
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile("data/arialuni.TTF", "Arial Unicode MS");
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile("data/simsunb.ttf", "SimSun-ExtB");

The async method for MacOS was added in the 2017.1.8 buld:

static addOpentypeFontFileAsync(callback: Function, filePath: string, fontName: string = null)

0 Comments

Please sign in to leave a comment.
Powered by Zendesk