Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF : Very large PDF file when using 'Calibri Light' font and bolding Options
Wolters Kluwer Legal Software France
Posted: Friday, August 26, 2022 12:43:39 PM
Rank: Newbie
Groups: Member

Joined: 4/7/2021
Posts: 2
Hi,

I realised that using the "Calibri Light" font with bolding that the generation took much longer and that the file was much bigger (several tens of megabytes if there is a lot of text) than with other fonts (Calibri for example).
Similarly, if I remove the bolding but leave the "Calibri Light" font, the generated file has a normal weight.
So I think there is a major bug with some fonts when there is bolding.
I tested this with the latest version of EO.PDF but also with previous versions.
The test file I generate with the font "Calibri Light" without bolding is 152KB.
The test file I generate with the "Calibri Light" font WITH bolding is 158700KB ! :


Here is the CSS code that causes this bug:
Code: HTML/ASPX
<style>body,p,ul,li{font-family:'Calibri Light';font-weight:bold;}</style>


The C# code to reproduce this problem is very simple:


I sent on the contact form, my example .NET 6 project to reproduce this problem.

Best regards
eo_support
Posted: Friday, August 26, 2022 3:03:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,103
Hi,

This is because the bold variant of the Calibri Light font is being synthesized. When a font variant can be found on the system, the corresponding font file for that font will be used. However if a font variaint is not found, it must be synthesized on the fly. This would result in the drawing instructions for each character being copied into each page, which can increase the processing time and file size exponentially.

For text that uses an existing font, the pseudo code in the pdf page would be:

Code:
use font "Calibri Light"
draw "hello there"


The font file which is embedded in the PDF would contains detailed drawing instructions for each characther. This results in signficiant saving when you have repeating characters. For example, in "hello there", "e" occurs 3 times and "l" occurs 2 times, the drawing instructions for letter "e" and "l" are only stored once in the font file.

However for synthesized font variant, it must copy the entire drawing instructions for each letters. So a simple
Code:
draw "hello there"


Would become something like this:
Code:
full drawing instructions for letter "h"
full drawing instructions for letter "e"
full drawing instructions for letter "l"
full drawing instructions for letter "l"
full drawing instructions for letter "o"
space
full drawing instructions for letter "t"
full drawing instructions for letter "h"
full drawing instructions for letter "e"
full drawing instructions for letter "r"
full drawing instructions for letter "e"

Each letter would contains a lot of drawing instructions. The synthesize process works by modifing the arguments for these instructions. For example, one of the instructions to draw letter "h" would be a line instruction to draw the "|" part, synthesize process would increase the line width of this drawing instruction to produce a heavier "|" for the letter "h".

This process produce the best text quality but unfortunately it also produce huge files. Our old version uses offset method to synthesize bold effect and it produces much smaller file. The pseudo code for that process is something like this:

Code:
use font "Calibri Light"
draw "hello there"
offset 1, 1
draw "hello there"


This produces much smaller file however the quality of the result text is not acceptable, especially for printing purpose.

Unfortunately the only way to resolve this issue is to make sure the corresponding font variant is installed on the system (or loaded with @fontface CSS directive).

Thanks
Wolters Kluwer Legal Software France
Posted: Monday, August 29, 2022 4:35:14 AM
Rank: Newbie
Groups: Member

Joined: 4/7/2021
Posts: 2
Hi,

Is it possible to deactivate this "synthesizing" with an option?
We aren't necessarily aware of the fonts that our customers will use, so if we could deactivate this synthesizing or use another font instead when it isn't installed on the system, it would be easier for us.

Best regards
eo_support
Posted: Monday, August 29, 2022 9:19:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,103
That does makes sense. We will look into it and see what we can do.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.