Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian KDE (http://www.linux-archive.org/debian-kde/)
-   -   Is okular unable to open gzipped PDFs? (http://www.linux-archive.org/debian-kde/657709-okular-unable-open-gzipped-pdfs.html)

Stanley Schade 04-19-2012 04:46 PM

Is okular unable to open gzipped PDFs?
 
On Thursday 19. April 2012, 15:54:44 Diederik de Haas wrote:
> On Thursday 19 April 2012 12:04:34 Stanley Schade wrote:
> > I'm running a Debian testing system with KDE 4.7.4. When I try to open a
> > file with the extension .pdf.gz with okular the following error message
> > shows up:
> >
> > "Could not open /path/to/file.pdf.gz"
>
> What if you decompress ("gunzip /path/to/file.pdf") the file and then do
> "file /path/to/file.pdf"? Does it say it's a pdf file?

Yes, it says: "file.pdf: PDF document, version 1.5" and can be opened by
okular. I've also tried compressing PDF documents and opening them with
okular. This did not work as well.

> > Furthermore okular complains that it "can not find a plugin which is able
> > to handle the document being processed". I wonder if I am the only one
> > to experience this behaviour since okular is linked to gzip-compressed
> > PDF documents by default
>
> There's the okular-extra-backends package, but I doubt it'll solve your
> issue. I just gzipped a pdf file and okular opens it without problems on
> my system.

okular-extra-backends doesn't solve the problem. Thank you for your feedback
anyway!

> > according to a bug report (see link below) that I've
> > found it should be able to cope with *.pdf.gz files.
> >
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=255586
>
> It would be better to link against the kde bug, since the debian bug only
> says "won't fix" for another package, namely kpdf

The KDE bug ( https://bugs.kde.org/show_bug.cgi?id=102704 ) is related to kpdf
as well. I just referred to it because, in the discussion. someone stated that
opening compressed PDF documents is implemented in okular.


--
To UNSUBSCRIBE, email to debian-kde-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201204191846.15890.nood0131@web.de">http://lists.debian.org/201204191846.15890.nood0131@web.de

Diederik de Haas 04-19-2012 05:44 PM

Is okular unable to open gzipped PDFs?
 
On Thursday 19 April 2012 18:46:15 Stanley Schade wrote:
> On Thursday 19. April 2012, 15:54:44 Diederik de Haas wrote:
> > On Thursday 19 April 2012 12:04:34 Stanley Schade wrote:
> > > I'm running a Debian testing system with KDE 4.7.4. When I try to open
> > > a file with the extension .pdf.gz with okular the following error
> > > message
> > >
> > > shows up:
> > >
> > >
> > > "Could not open /path/to/file.pdf.gz"
> >
> >
> >
> > What if you decompress ("gunzip /path/to/file.pdf") the file and then do
> > "file /path/to/file.pdf"? Does it say it's a pdf file?
>
> Yes, it says: "file.pdf: PDF document, version 1.5" and can be opened by
> okular. I've also tried compressing PDF documents and opening them with
> okular. This did not work as well.

I've tried opening X.pdf.gz files from version 1.3, 1.4, 1.5 and 1.6 and they all open fine here.
When I compress a pdf file in Dolphin (with Ark) it turns into a X.pdf.tar.gz file and then I do get
the error you're describing. But I do have to explicitly open them with Okular, since it defaults to
Ark with that extension.

Other then that, I don't know.
(I do run Sid, but it's unlikely to be relevant)

Diederik


--
To UNSUBSCRIBE, email to debian-kde-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201204191944.32048.didi.debian@cknow.org">http://lists.debian.org/201204191944.32048.didi.debian@cknow.org

Stanley Schade 04-19-2012 07:45 PM

Is okular unable to open gzipped PDFs?
 
On Thursday 19 April 2012 19:44:31 Diederik de Haas wrote:
> On Thursday 19 April 2012 12:04:34 Stanley Schade wrote:
> > I'm running a Debian testing system with KDE 4.7.4. When I try to
> > open a file with the extension .pdf.gz with okular the following
> > error message
> >
> > shows up:
> >
> >
> > "Could not open /path/to/file.pdf.gz"
>
> [...]
> I've tried opening X.pdf.gz files from version 1.3, 1.4, 1.5 and 1.6 and
> they all open fine here. When I compress a pdf file in Dolphin (with Ark)
> it turns into a X.pdf.tar.gz file and then I do get the error you're
> describing.

Thank you for your patience and your help, Diederik. By now I've figured out
the problem. When running okular from a terminal, it said:

$ okular /path/to/file.pdf.gz
...
okular(3581)/okular (app) Okular::Document::openDocument: No plugin for
mimetype '"text/x-matlab"'.
...

This reminded me of changes I made to /usr/share/doc/packages/freedesktop.xml
and possibly some other mime-related files. Reinstalling the package shared-
mime-info fixed the issue. 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.)

Thus, I still consider this to be strange behaviour of okular. In case I figure
out why it determined the wrong mimetype, I'll submit another post as a
follow-up.

Stanley



--
To UNSUBSCRIBE, email to debian-kde-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201204192145.49857.nood0131@web.de">http://lists.debian.org/201204192145.49857.nood0131@web.de

Pino Toscano 04-19-2012 09:24 PM

Is okular unable to open gzipped PDFs?
 
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`.

In case of this "compressed XXX document"-like mimetypes, you can easily
check what is the mimetype (only by checking the file content though, so
it could not always give a "good" result) of the compresse document
doing
$ gunzip -c foo.pdf.gz | kmimetypefinder -c -

> 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:
1. determine its mimetype
2. is it a compressed file (gzip, bzip2, or xz)? if so:
2a. uncompress it
2b. consider the uncompresed file the "new" file to open
2c. determine its mimetype
3. pick the first generator that handles said mimetype
4. does 3. succeed? if so, it ends here
5. determines again the mimetype of the file, but now only considering
its content (and no more the file name eventually used in previous
steps)
6. is this new mimetype different than the previously used one? if so:
6a. pick the first generator that handles said mimetype
6b. does 6a. succeed? if so, it ends here
7. all the attempts failed, so complain that the file couldn't be open

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).
Unfortunately there isn't nothing much that can be done in such cases,
as the only viable alternative should be uncompressing compressed files,
which you can guess it would be too expensive for what should be a
"fast" operation.

--
Pino Toscano

Stanley Schade 04-19-2012 11:43 PM

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
before.

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


--
To UNSUBSCRIBE, email to debian-kde-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201204200143.39588.nood0131@web.de">http://lists.debian.org/201204200143.39588.nood0131@web.de


All times are GMT. The time now is 07:52 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.