Okular bookmarks, annotations lost for renamed PDFs, etc. (Okular 0.16.2, KDE 4.10.2)
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okular bookmarks, annotations lost for renamed PDFs, etc. (Okular 0.16.2, KDE 4.10.2)
Okular stores PDF bookmarks and annotations in ~/.kde/share/apps/okular/docdata. However, when I rename a PDF document, its associated bookmarks and annotations are lost because docdata still contains the PDF document's old filename.
How do I restore PDF bookmarks and annotations to PDFs whose filenames have changed?
How do I restore PDF bookmarks and annotations to PDFs whose filenames have changed?
The xml files in ~/.kde/share/apps/okular/docdata are named this way:
Code:
<size>.<file>.xml
Where <size> is the file size in bytes and <file> is the file name.
So let's suppose I have a test.pdf file which is 4667911 bytes in size. I open it with Okular and add some annotations. This creates a 4667911.test.pdf.xml in the docdata directory.
Then I rename test.pdf to renamed.pdf, and open it in Okular, which creates 4667911.renamed.pdf.xml. But, as you mention, there are no bookmarks nor annotations. They remain in 4667911.test.pdf.
So, copy (or move) 4667911.test.pdf.xml to 4667911.renamed.pdf.xml. That should solve your problem.
Good luck!
EDIT: Disclaimer: I have KDE 4.8.5 and Okular 0.14.3, so I don't know if okular changed the file format in any way. I suppose not. YMMV.
The xml files in ~/.kde/share/apps/okular/docdata are named this way:
Code:
<size>.<file>.xml
Where <size> is the file size in bytes and <file> is the file name.
So let's suppose I have a test.pdf file which is 4667911 bytes in size. I open it with Okular and add some annotations. This creates a 4667911.test.pdf.xml in the docdata directory.
Then I rename test.pdf to renamed.pdf, and open it in Okular, which creates 4667911.renamed.pdf.xml. But, as you mention, there are no bookmarks nor annotations. They remain in 4667911.test.pdf.
So, copy (or move) 4667911.test.pdf.xml to 4667911.renamed.pdf.xml. That should solve your problem.
Thanks, but I've tried this, and unfortunately to no avail. I think ~/.kde/share/apps/okular/bookmarks.xml still contains the old filename, too…
Yes, you're right. The method I mentioned before works fine with annotations, but not with bookmarks. Sorry about that.
The bookmarks.xml file hold the bookmarks for all documents opened in Okular. In my example test.pdf I added one bookmark, and this is what Okular adds to the file:
Each file opened gets a <folder> tag, and every bookmark for the file is stored inside a <bookmark> tag. The full pathname to the file is in the attribute href in both tags.
After changing this href value to the full path of renamed.pdf, the bookmarks created in test.pdf work in renamed.pdf. Have you tried this?
Yes, you're right. The method I mentioned before works fine with annotations, but not with bookmarks. Sorry about that.
The bookmarks.xml file hold the bookmarks for all documents opened in Okular. In my example test.pdf I added one bookmark, and this is what Okular adds to the file:
Each file opened gets a <folder> tag, and every bookmark for the file is stored inside a <bookmark> tag. The full pathname to the file is in the attribute href in both tags.
After changing this href value to the full path of renamed.pdf, the bookmarks created in test.pdf work in renamed.pdf. Have you tried this?
No, but it seems it would work, thanks. This would be a good feature request for future versions, where a dialog box would pop up asking to find the file's new location.
The bookmarks implementation in Okular demonstrates surprisingly little foresight. Not only is it easy for a PDF file to get separated from its bookmarks, manually correcting this is made more difficult by the fact that *each* bookmark contains a full path to its PDF file in bookmarks.pdf!
If the bookmarks for a file were stored in a folderish element having a tag or attribute of the file's path, it would be workable to move a PDF file and just change a single entry. The way it currently is makes it unlikely many users will be able to *ever* move a file and keep its bookmarks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.