Estimated read time: 2 minutes
pdfium is the rendering library used in Chromium’s pdf viewer. It’s based on the foxit pdf renderer and its rendering quality is much better compared to the pre-existing "convert PDF to ODG, then to an image" code when it comes to just viewing a PDF file. First, thanks to PMG who made this work possible.
Let’s look at a few samples that compare the old pdfimport rendering result and the new pdfium-based one. One important feature is that embedded fonts are handled. This is how this inserted PDF looked like previously:
Compare it with the new result:
Now let’s see the front page of a magazine, you can see 4 unexpected artifacts:
New result:
Finally a problem with pdfium was that LibreOffice got bitmaps from it, so in case you re-exported to PDF, the quality of these PDF images were worse than in the original PDF file. The PDF specification has a reference XObject feature that helps in this case: it allows the PDF export to still write the bitmap to the exported PDF, but in case the reader supports this feature, the vector-based original file will be shown, not the bitmap.
Here is a simple hand-crafted star in a PDF file, as it looked initially:
This is how it looks after LibreOffice’s PDF export learned to emit reference XObjects:
All this is available in LibreOffice master, towards 5.4.