Linux - Software This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
05-01-2013, 11:28 PM
|
#1
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 530
Rep:
|
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?
thank you
|
|
|
05-02-2013, 01:34 AM
|
#2
|
Member
Registered: Jun 2011
Distribution: Slackware
Posts: 515
|
Quote:
Originally Posted by Geremia
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:
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.
Last edited by Diantre; 05-02-2013 at 01:40 AM.
|
|
|
05-02-2013, 12:34 PM
|
#3
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 530
Original Poster
Rep:
|
Quote:
Originally Posted by Diantre
The xml files in ~/.kde/share/apps/okular/docdata are named this way:
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…
|
|
|
05-02-2013, 03:05 PM
|
#4
|
Member
Registered: Jun 2011
Distribution: Slackware
Posts: 515
|
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:
Code:
<folder href="file:///tmp/test.pdf">
<title>/tmp/test.pdf</title>
<bookmark href="file:///tmp/test.pdf#18">
<title>#19</title>
<info>
<metadata owner="http://freedesktop.org">
<bookmark:icon name="application-pdf"/>
</metadata>
</info>
</bookmark>
</folder>
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?
|
|
1 members found this post helpful.
|
05-04-2013, 02:51 PM
|
#5
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 530
Original Poster
Rep:
|
Quote:
Originally Posted by Diantre
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:
Code:
<folder href="file:///tmp/test.pdf">
<title>/tmp/test.pdf</title>
<bookmark href="file:///tmp/test.pdf#18">
<title>#19</title>
<info>
<metadata owner="http://freedesktop.org">
<bookmark:icon name="application-pdf"/>
</metadata>
</info>
</bookmark>
</folder>
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.
|
|
1 members found this post helpful.
|
10-21-2019, 03:34 PM
|
#6
|
LQ Newbie
Registered: Oct 2007
Posts: 9
Rep:
|
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.
Last edited by tmst; 10-21-2019 at 03:35 PM.
|
|
|
10-22-2019, 06:27 AM
|
#7
|
Senior Member
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683
|
I have no idea if Okular can rename files
but that is the only way the metadata could be migrated
regardless of the structure of the metadata files, a simple sed
Code:
sed -i.backup-$(date +%F) 's/oldfilename.pdf/newname.pdf/' ~/.kde/share/apps/okular/docdata/*.xml
would fix it
doesn't matter how many entries
would the average user reach for sed ?
probably not
|
|
|
All times are GMT -5. The time now is 01:07 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|