Bug 493622 - Signing a small pdf document increases its size tremendously
Summary: Signing a small pdf document increases its size tremendously
Status: RESOLVED UPSTREAM
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-25 08:23 UTC by Oliver Sander
Modified: 2024-10-04 12:34 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Test file (21.86 KB, application/pdf)
2024-09-25 08:23 UTC, Oliver Sander
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Sander 2024-09-25 08:23:53 UTC
Created attachment 174060 [details]
Test file

Signing a small pdf file increases its size a lot.  The attached test file goes from 24KB to 17MB.  I guess a bit of size increase is expected, but not that much.


SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux 12
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.10.9-amd64 (64-bit)
Graphics Platform: offscreen
Processors: 8 × Intel® Core™ i7-8565U CPU @ 1.80GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Comment 1 Oliver Sander 2024-09-25 08:26:30 UTC
I can't attach the signed test file (it's too big), but you can download it from https://datashare.tu-dresden.de/s/XDjHYGzpdd2jtCo .
Comment 2 Nicolas Fella 2024-10-01 11:17:27 UTC
The size increase comes from Noto fonts being embedded into the file now
Comment 3 Oliver Sander 2024-10-01 11:35:41 UTC
Is that intentional? Is that necessary? All of a sudden Thunderbird warns me when I want to send a signed one-page text document, because the file is so big.
Comment 4 Sune Vuorela 2024-10-01 11:48:37 UTC
(In reply to Oliver Sander from comment #3)
> Is that intentional? Is that necessary? All of a sudden Thunderbird warns me
> when I want to send a signed one-page text document, because the file is so
> big.

I really hope it is not intentional. I have put quite some resources into not embedded fonts for the fun of it; only those that are actually used. 

This file seems to have following embedded:

BAAAAA+LiberationSerif               
Helvetica
Noto Sans CJK JP Regular
Arimo Regular
FreeSans Regular
DejaVu Sans Book

The first one is likely the original subsetted font from the original document, and the other ones are added as part of the signature creation?

Oliver: can you confirm with `pdffonts` that the original document only embeds the subsetted LiberationSerif font ?
Comment 5 Oliver Sander 2024-10-01 14:18:16 UTC
The original document is the one attached to this bug report.

~/tmp> pdffonts hallo-welt.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BAAAAA+LiberationSerif               TrueType          WinAnsi          yes yes yes     11  0
~/tmp>
Comment 6 Sune Vuorela 2024-10-03 12:51:21 UTC
Yeah. the new signature flow in poppler mishandles text encoding and thus everything looks like weird unicode glyphs to the font embedding code.
Comment 8 Oliver Sander 2024-10-03 15:06:35 UTC
Thank you Sune! I tested the patch and it does indeed solve the issue for me!

Incidentally, it also seems to fix https://bugs.kde.org/show_bug.cgi?id=493623 for me (where Okular wouldn't react for a while after signing).  Maybe it was embedding all those fonts that make Okular unresponsive.
Comment 9 Sune Vuorela 2024-10-04 12:34:45 UTC
(In reply to Oliver Sander from comment #8)
> Thank you Sune! I tested the patch and it does indeed solve the issue for me!
> 
> Incidentally, it also seems to fix
> https://bugs.kde.org/show_bug.cgi?id=493623 for me (where Okular wouldn't
> react for a while after signing).  Maybe it was embedding all those fonts
> that make Okular unresponsive.

It uses a bit of time to find and process the fonts, yes. So it could very well be that.

Will mark this and the other as fixed upstream.