[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is okular unable to open gzipped PDFs?

Am Donnerstag, 19. April 2012, 23:24:26 schrieb Pino Toscano:
> Alle giovedì 19 aprile 2012, Stanley Schade ha scritto:
> > However, using the command "mimetype" returned the
> > correct mimetype and so did the properties dialog which can be
> > accessed by right-clicking on the file in dolphin:
> > 
> > $ mimetype file.pdf.gz
> > 
> >    file.pdf.gz: application/x-gzpdf
> > 
> > (Of course I checked that before reinstalling shared-mime-info.)
> Usually extensions have a slightly higher priority when matching
> freedesktop.org mimetypes, so foo.pdf.gz is usually considered
> application/x-gzpdf (i.e. a PDF document compressed with gzip).
> It seems that `mimetype` is part of a perl module for fdo mimetypes
> (never heard of it before); if you want to check closer how kde
> applications see file types, you can use `kmimetypefinder`.

Thank you for your detailed explanation. I did some research on my own and 
figured out, that I should use "xdg-mime query filetype <filename>" to determine 
the mime type of a file rather than "mimetype". This gives me the same results 
as the kmimetypefinder which you proposed. (Well, kmimetypefinder provides some 
extra information about the accuracy and is more convenient to use.)

> > Thus, I still consider this to be strange behaviour of okular.
> There's nothing strange: basically what okular does when asked to open a
> file is the following:
> [very detailed and comprehensible explanation]

I also finally realized that the error was caused by my modification of 
/usr/share/mime/packages/freedesktop.org.xml and is not due to any strange 
behaviour of okular.
In order to have .m-files detected as text/x-matlab I set the magic priority of 
*.m-files beginning with a %-sign from 10 to 60. I have no deep knowledge about 
freedesktop.org.xml, but it seems that this change made any file starting with 
a %-sign being detected as text/x-matlab. Unfortunately gzipped PDF documents 
begin with the line "%PDF-1.5". Therefore they were assigned the wrong 
mimetype as well. By now I've changed the magic priority to 11 and everything 
is just working fine.

> As you can see (hope it is clear and I didn't make it confused :) ),
> okular does not mind the "pdf" part in the application/x-gzpdf mimetype
> determined initially for your document; what "gives you the feeling"
> it's a document is, as said above, because the mimetype detection (as
> used normally in dolphin, the file dialog, etc) thinks foo.pdf.gz is a
> gzipped PDF (even if it's, say, a XML file renamed to .pdf and
> compressed with gzip).

I found your explanation very helpful. In particular I didn't know that 
dolphin uses a different approach to detect mimetypes. I think this confused me 

Thanks for pointing out all those things and giving your spare time to help me 
resolve my issue! (This goes to Diederik as well.)

Reply to: