LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 05-01-2013, 11:28 PM   #1
Geremia
Member
 
Registered: Apr 2011
Distribution: slackware64-current
Posts: 421

Rep: Reputation: 43
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
 
Old 05-02-2013, 01:34 AM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 230Reputation: 230Reputation: 230
Quote:
Originally Posted by Geremia View Post
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.

Last edited by Diantre; 05-02-2013 at 01:40 AM.
 
Old 05-02-2013, 12:34 PM   #3
Geremia
Member
 
Registered: Apr 2011
Distribution: slackware64-current
Posts: 421

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by Diantre View Post
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…
 
Old 05-02-2013, 03:05 PM   #4
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 230Reputation: 230Reputation: 230
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.
Old 05-04-2013, 02:51 PM   #5
Geremia
Member
 
Registered: Apr 2011
Distribution: slackware64-current
Posts: 421

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by Diantre View Post
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.
Old 10-21-2019, 03:34 PM   #6
tmst
LQ Newbie
 
Registered: Oct 2007
Posts: 9

Rep: Reputation: 0
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.
 
Old 10-22-2019, 06:27 AM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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
 
  


Reply

Tags
bookmarks, kde, pdf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] KDE how to ark to call Okular? matiasar Linux - Software 2 02-23-2013 12:45 PM
To the effect of, starting kubuntu, and Okular not opening PDFs automatically. Bhakta Neal Linux - Newbie 1 07-22-2012 04:10 PM
LXer: Annotating PDFs With the Open-Source Software Package Okular LXer Syndicated Linux News 0 03-23-2010 10:42 PM
kde 4 - kubuntu - okular with japanese fonts checkmate3001 Linux - Software 1 02-24-2009 03:17 AM
Why Do I Need KDE for Okular PDF Reader?? taurusx5 Linux - Software 1 04-03-2008 08:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration