Bug 336658

Summary: Some PDF previews show a wrong page size surrounding the picture with a white border or area
Product: [Unmaintained] kio Reporter: Leonardo Giordani <giordani.leonardo>
Component: thumbnailAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: aacid, frank78ac, nate
Priority: NOR    
Version: 4.13.2   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
URL: https://drive.google.com/folderview?id=0B8dlXBUSEZtPY19CSTBvNW9QTDA&usp=sharing
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Leonardo Giordani 2014-06-24 13:53:27 UTC
I get a very strange behaviour in Dolphin when dealing some PDF files (I do not yet know why just some of them). The preview shows an image that is larger than the actual page, with a big white area. I tried to split the PDF (pdftk burst) and the thumbnails of some of them have the same problem.

When opening the PDF with Okular, Gimp or other programs everything works perfectly.

The attached URL shows 2 examples of this behaviour. In the first one the image is also surrounded by a white border which is invisible in Gimp or Okular.

I found kdegraphics-thumbnailers.git and tried the gs cmdline directly in bash. The problem is probably there since the resulting PNG contains the white area.

Since the PDF is copyrighted I cannot post it but I got plenty of PDFs, mostly commercial ones, that behave this way.

Reproducible: Always

Steps to Reproduce:
1. Open Dolphin with PDF thumbnails active
2. Browse the PDF file directory 

Actual Results:  
PDF thumbnail contains white areas

Expected Results:  
PDF thumbnail shall be the same as shown by Okular

I'm available to send the PDFs with this problem.
Comment 1 Frank Reininghaus 2014-06-24 14:00:35 UTC
Thanks for the bug report. I guess that means that you did not find any useful info in the thumbnailer code (see [1]) ?

Since the thumbnailer is not part of Dolphin, this is most likely not a Dolphin bug (unless the thumbnails in FolderView and the file dialog in, e.g., KWrite look different), so I'll reassign.

[1] http://lists.kde.org/?t=140361031200001&r=1&w=2
Comment 2 Frank Reininghaus 2014-06-24 14:07:06 UTC
(In reply to comment #0)
> I found kdegraphics-thumbnailers.git and tried the gs cmdline directly in
> bash. The problem is probably there since the resulting PNG contains the
> white area.

In that case, it would be awesome if you could either find better command line arguments for gs, or propose another method that can be used to create better PDF thumbnails. Please note that kdegraphics-thumbnailers.git has not seen any real commits in years, so it seems that it's basically unmaintained, and thus, it seems unlikely that anyone will read this report and fix it :-(
Comment 3 Leonardo Giordani 2014-06-24 14:10:38 UTC
Ok, I'll try to check the code and the gs command line. It's a pity that such a component is left there unmaintained...
Comment 4 Leonardo Giordani 2014-06-27 06:43:49 UTC
It turn out that the problem is in the way the PDF boxes are managed by the thumbnailer. The "wrong" PDFs have a MediaBox which is larger that the TrimBox, as it may happen since MediaBox is used to specify the whole page size, to issue cropping inaccuracies etc. Many PDFs just specify MediaBox and TrimBox the same size (when not intended for printing, probably) and everything works perfectly in that case.

How does oKular deal with PDF boxes? Does it show the content of the TrimBox?

The "gs" command used in the thumbnailer may be corrected with "-dUseTrimBox", which in my case returns a perfect preview.

May someone help me in fixing the bug? I mean testing, reviewing, committing, etc? I never did a fix on the KDE codebase ;)
Comment 5 Frank Reininghaus 2014-07-01 15:14:51 UTC
Thanks for investigating the problem!

(In reply to comment #4)
> How does oKular deal with PDF boxes? Does it show the content of the TrimBox?

I don't know, sorry. You would have to ask on the Okular mailing list

https://mail.kde.org/mailman/listinfo/okular-devel

> May someone help me in fixing the bug? I mean testing, reviewing,
> committing, etc? I never did a fix on the KDE codebase ;)

Yes, sure! Patch review usually takes place at

https://git.reviewboard.kde.org/

Probably the 'kdegraphics' group should be added to any review request concerning the thumbnailers. For testing, it would be best if a PDF with which the problem can be reproduces was available publicly.
Comment 6 Albert Astals Cid 2014-07-15 19:49:30 UTC
TrimBox is the wrong box to use, cropbox is what you want when showing a pdf in screen as http://www.prepressure.com/pdf/basics/page-boxes says
Comment 7 Nate Graham 2018-06-29 20:56:44 UTC
This works for me using the latest version of kdegraphics-thumbnailers, and by browsing the code, I see why: it is indeed using CropBox now.