Bug 378843 - Printing to pdf file produces a file with no text and no embedded fonts
Summary: Printing to pdf file produces a file with no text and no embedded fonts
Status: REOPENED
Alias: None
Product: konqueror
Classification: Applications
Component: webenginepart (show other bugs)
Version: 5.0.97
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-16 15:44 UTC by skeve
Modified: 2020-11-18 22:03 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
pdf after printing from Konqueror with WebEngine (978.93 KB, application/pdf)
2017-04-16 15:44 UTC, skeve
Details
pdf file created with KHTML engine (27.95 KB, application/pdf)
2017-04-16 15:45 UTC, skeve
Details

Note You need to log in before you can comment on or make changes to this bug.
Description skeve 2017-04-16 15:44:31 UTC
Created attachment 105047 [details]
pdf after printing from Konqueror with WebEngine

Printing to pdf file from Konqueror or KMail produces pdf file that doesn't have any searchable text - there's no fonts embedded and everything looks quite ugly (see attached print.pdf). I installed cups-pdf, and the result is the same. But when I print to pdf file from GTK apps like firefox or thunderbird, I get normal pdf with selectable text and embedded fonts. The properties of the resulting files show that the producer of the file is Qt 5.8.0 for KDE-generated ones and cairo 1.9.5 for GTK-generated.

If I change the web engine in Konqueror from WebEngine to KHTML, there's another problem (images won't load), but the resulting pdf file is a good one.
Comment 1 skeve 2017-04-16 15:45:36 UTC
Created attachment 105048 [details]
pdf file created with KHTML engine
Comment 2 Attila 2018-09-23 09:41:02 UTC
I can confirm this bug. It still exists in Fedora 28 with the latest updates.

- konqueror-18.04.3-1.fc28.x86_64
- kmail-18.04.3-1.fc28.x86_64

When I set the rendering engine to KHTML or Wegkit the result of the PDF-File seems to be OK, but set to Webengine the output doesn't have any text or embedded fonts.

There is no option for Kmail to set the rendering engine, so the PDF-File doesn't have any text or embedded fonts. The quality of the PDF-File is very poor.
Comment 3 Saeid Akbari 2019-08-28 21:18:29 UTC
Confirming. KMail 19.04.3 on Gentoo, with KDE Frameworks 5.60
Comment 4 Attila 2019-09-02 19:25:05 UTC
I can confirm on Fedora 30 

KDE Plasma Version: 5.15.5
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.4
Comment 5 skeve 2019-09-03 08:33:30 UTC
It still is the same in the current Arch:

plasma-desktop 5.16.4-1
plasma-framework 5.61.0-1
qt5-webengine 5.13.0-4
Comment 6 Attila 2019-09-24 07:52:16 UTC
Hi,

it's been now more the two years since this bug has been reported and the bug still exists. I am wondering why we don't receive any answer. On one hand the developers encourage us user to report bugs and on the other hand they don't reply. I respect it if there is no maintainer for this project, but please reply and say yes, no, maybe or tell us that there is no developer yet.
I hope you guys don't mind it if I say my opinion, even if this is a wrong place for, but two years without any answer is definitely too much time.

And again: it affects KMail as well.
Comment 7 Christoph Feck 2019-10-24 07:39:17 UTC
If this is reproducible with Qt 5.13 or newer, please report this issue directly to QtWebEngine developers via https://bugreports.qt.io/
Comment 8 Attila 2019-10-24 18:39:03 UTC
Thanks for your reply.
Unfortunately Qt 5.13 is not available on Fedora 30 but hopefully on Fedora 31.
I will give it a try then and if it still doesn't work, I will report it to QtWebEngine developers.
Comment 9 Attila 2019-10-24 20:35:28 UTC
I have just tested on KDE Neon (Qt 5.13.1). It is reproducible. I have reported the issue to QtWebEngine developers.

https://bugreports.qt.io/browse/QTBUG-79527

Perhaps someone should change here the status to "reopened" or "verified" because the issue is definitely not resolved.
Comment 10 Attila 2019-11-11 20:09:26 UTC
(In reply to Christoph Feck from comment #7)
> If this is reproducible with Qt 5.13 or newer, please report this issue
> directly to QtWebEngine developers via https://bugreports.qt.io/

Could you please take a look at "https://bugreports.qt.io/browse/QTBUG-79527". They say that this "https://doc.qt.io/qt-5/qwebenginepage.html#printToPdf" should be used to generate searchable pdf files.
Comment 11 Kevin Kofler 2020-11-17 00:35:10 UTC
Printing to PDF with QtWebEngine must use printToPdf, not print. See the code in Falkon:
https://invent.kde.org/network/falkon/-/blob/ba4f18478141e3909770b3b2cf59903166dd34cc/src/lib/webengine/webview.cpp#L402

The print method is a hack which prints to a temporary PDF, rasterizes the PDF with the bundled PDFium (!) and then sends the raster output to the QPainter (because there is unfortunately no code in Qt to render a PDF to a QPainter without rasterizing it). When the goal is to print to a PDF, this creates a bitmap blob wrapped in a PDF instead of a normal PDF. The way to work around that issue is to use printToPdf, which keeps the initial PDF and does no further processing to it.

Konqueror's KWebEnginePart just always uses print:
https://invent.kde.org/network/konqueror/-/blob/df3f50f10ad82921f54d2937e278d65e1e7ed2b4/webenginepart/src/webenginepart_ext.cpp#L281

And so does KMail:
https://invent.kde.org/pim/messagelib/-/blob/9caf5ef74e0e85aa371984b3bb8b447f6ca7ff6a/messageviewer/src/viewer/viewer_p.cpp#L2376
Comment 12 skeve 2020-11-18 19:38:05 UTC
I can confirm that printing to pdf from Falkon works as it supposed to.
Meanwhile, the problem for konqueror and kmail is still there:

plasma-desktop 5.20.3-1
plasma-framework 5.76.0-1
qt5-webengine 5.15.1-3

konqueror 20.08.3-1
kmail 20.08.3-1
Comment 13 Kevin Kofler 2020-11-18 22:02:59 UTC
KMail should be fixed by:
https://invent.kde.org/pim/messagelib/commit/9538a30356896ea0c0ee80dfd2f0899f33be5cc0
(see bug #422095).
Comment 14 Kevin Kofler 2020-11-18 22:03:44 UTC
(Please note that the referenced KMail commit was authored and pushed yesterday and has not yet made it out to any release.)