Bug 338742 - Annotations incompatible with gzip
Summary: Annotations incompatible with gzip
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 0.19.3
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-02 01:26 UTC by Holger
Modified: 2018-04-18 15:19 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Holger 2014-09-02 01:26:23 UTC
Only recently I found out, that Okular can handle *.pdf.gz ... very useful!

Problem is, I've already made annotations in the files, I'd like to gzip. But after gzip Okular won't find my annotations anymore. Only the unzipped PDF gets annotations.

Reproducible: Always

Steps to Reproduce:
1. Open uncompressed PDF
2. Add some annotations
3. Close PDF
4. Move PDF to other folder
5. Check in Okular (anotations still present)
6. gzip PDF
7. Check in Okular (anotations are gone)
8. gunzip PDF
9. Check in Okular (anotations resurrected)

Actual Results:  
Detection of "same" file can find annotations after moving to another folder, but not after gzip compression

Expected Results:  
I'd like to suggest to add a fallback to re-recognize more similar documents
- if a hash is calculated, don't hash the gzip, but the uncompressed PDF
- in addition check the embedded ID within the trailer of the PDF
Comment 1 Robert Gernert 2017-11-25 20:18:06 UTC
works for me using okular version 0.24.2
Comment 2 null 2017-11-26 22:37:22 UTC
For KDE Applications 17.12 Beta, Okular's annotation saving handling for PDFs was changed from saving to an external XML file to modifying the PDF directly. Therefore this changes the situation a bit.

However, it still does not work. We get "The file 'a.pdf.gz' has been modified by another program, which means it can no longer be saved.". Even worse, "Save As" does not work either, meaning any annotations added to a gzipped PDF cannot be saved in any way.

Workaround to still get a gzipped file: Unzip PDF, open in Okular, save as "Okular document archive" (which is a tar.gz, actually).

Nevertheless, this should be fixed as the workaround is not obvious for regular users. Reverting 559836c39270 solves the issue as well as the old bug for me, so the fix is probably easy (some special timestamp handling for gzipped files?).
Comment 3 Robert Gernert 2017-11-30 19:14:05 UTC
Please excuse my lack of politeness. That comment of mine was not nice. Thank you very much that you answered properly nevertheless. I will try to follow your example.
Comment 4 null 2017-11-30 19:29:04 UTC
Huh? I see no issues with your comment, it was just a data point. Those things can be very useful to speed up bug triaging, actually.

The rest are just insights I had gathered in the last weeks working on the code, nothing you could have known.

Keep it up :) (But you should upgrade your Okular version before triaging / commenting on bugs, 0.24.2 is really old…)
Comment 5 null 2018-01-02 17:08:36 UTC
Patch: https://phabricator.kde.org/D9580
Comment 6 Albert Astals Cid 2018-02-05 23:32:02 UTC
Git commit ad1160be1b370ca512a741c1a12f9eff0ca5848c by Albert Astals Cid, on behalf of Henrik Fehlauer.
Committed on 05/02/2018 at 23:31.
Pushed by aacid into branch 'Applications/17.12'.

Fix saving annotations to gzipped files

Okular supports opening zipped files like document.pdf.gz by
transparently extracting them. However, since 559836c39270 saving
annotations back was broken. This is because this commit tries to
prevent saving back changes to externally modified files to prevent data
loss. The way this is checked by comparing timestamps mistakenly
triggered for unchanged zipped files, too.

This can be solved by always comparing the before/after timestamps of
the actual file, instead of the timestamp of the temporary copy of the
extracted file. The change has to be done in two places so saving
repeatedly works too.

Test plan
    gzip autotests/data/file1.pdf && okular file1.pdf.gz
    Add annotation, saving works now instead of showing an error.
    touch normal.pdf still triggers modification warning.

Differential Revision: https://phabricator.kde.org/D9580

M  +2    -2    part.cpp

https://commits.kde.org/okular/ad1160be1b370ca512a741c1a12f9eff0ca5848c