Welcome Guest Search | Active Topics | Sign In | Register

CSS background with border-radius high impact on PDF size Options
Dap
Posted: Monday, January 24, 2022 11:43:37 AM
Rank: Newbie
Groups: Member

Joined: 9/22/2016
Posts: 7
Hi,

We encounter an issue with some of our reports which are no more sent by email because they reach the attachement size limit. Some of them have have more than doubled in size since we upgraded from EO.Pdf 2018 to EO.Pdf 2021.
After a deep inspection, we discovered that an intensive usage of border-radius seems to be the root cause of this.

You can easily reproduce the issue by converting a HTML table to PDF
If you apply the following style on each cell the size of the converted PDF highly increase with v2021:
td{
background-color:red;
border-radius:5px;
}

A simple 10x60 table conversion gives the following size :
v2018 no style : 23KB
v2021 no style : 21KB
v2018 with rounded background on cells : 52KB
v2021 with rounded background on cells : 134KB

Could you decrease the impact of such styles in a future release?

Thank you for your support
eo_support
Posted: Thursday, January 27, 2022 5:11:39 PM
Rank: Administration
Groups: Administration

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

Sorry about the delay. Can you send the two result PDF files to us so that we can look into the files? You can send it either using the contact us page or email it to us. See here for our email address:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!
eo_support
Posted: Friday, February 4, 2022 6:14:29 PM
Rank: Administration
Groups: Administration

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

We have looked into the files you sent to us and there doesn't appear to be an easy way to avoid the size increase. The root of the problem is the increased browser engine precision during the rendering. The result of the rendering is a list of coordinates. When the rendering precision increases, the coordinate values becomes much longer due to a higher precision number contains many more digits.

As an example, this is the result in the old PDF file that draws a rounded rectangle:

Code:
3 158 m
3 144 l
3 140.666672 4.6666665 139 8 139 c
19 139 l
22.333334 139 24 140.666672 24 144 c
24 158 l
24 161.333328 22.333334 163 19 163 c
8 163 l
4.6666665 163 3 161.333328 3 158 c
h
f


Each of the letters represents a drawing instruction, where as the numbers preceding the letter are parameters. So for example, the pseduo code for the first few lines would be like this:

Code: C#
m(3, 158);  //move
l(3, 144);    //lineTo
c(3, 140.666672, 4.6666665, 139, 8, 139);  //cubicCurveTo
....


Here each "c" command draws one corner.

In the newer PDF the instructions to draw the same rounded rectangle is like this:

Code:
3 158 m
3 144 l
2.9999998 143.33696 3.1268668 142.699142 3.3806016 142.086563 c
3.6343365 141.473999 3.9956245 140.933289 4.4644656 140.464462 c
4.9333067 139.995621 5.4740119 139.634323 6.0865822 139.380585 c
6.6991525 139.126862 7.3369584 139 8 139 c
19 139 l
19.663038 139 20.300844 139.126862 20.913414 139.380585 c
21.525984 139.634323 22.06669 139.995621 22.535532 140.464462 c
23.004372 140.933289 23.36566 141.473999 23.619394 142.086563 c
23.873129 142.699142 23.999998 143.33696 24 144 c
24 158 l
23.999998 158.663025 23.873129 159.300827 23.619394 159.913391 c
23.36566 160.525955 23.004372 161.066666 22.535532 161.535522 c
22.06669 162.004349 21.525984 162.365631 20.913414 162.61937 c
20.300844 162.873108 19.663038 162.999985 19 163 c
8 163 l
7.3369584 162.999985 6.6991525 162.873108 6.0865822 162.61937 c
5.4740119 162.365631 4.9333067 162.004349 4.4644656 161.535522 c
3.9956245 161.066666 3.6343365 160.525955 3.3806016 159.913391 c
3.1268668 159.300827 2.9999998 158.663025 3 158 c
h


Note that the new browser engine uses many more drawing instructions (three "c" commands to draw one corner) and also uses higher precision numbers (for example, 23.999998 instead of 24). Both contributed to a siginficant increase in size if you use rounded corner extensively. If you only contain a few rounded corners in the page, then the impact would not be too obvious.

As we are not in a position to change the way the browser engine's rendering process works, we are unable to change this behavior. Sorry about it!

Please feel free to let us know if you have any more questions.

Thanks!
Dap
Posted: Tuesday, February 8, 2022 8:55:59 AM
Rank: Newbie
Groups: Member

Joined: 9/22/2016
Posts: 7
OK, fine. We can live with that.
Thank you for this detailed answer.
eo_support
Posted: Tuesday, February 8, 2022 9:32:14 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,201
You are very welcome. Please feel free to let us know if there is anything else.


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.