LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Okular bookmarks, annotations lost for renamed PDFs, etc. (Okular 0.16.2, KDE 4.10.2) (http://www.linuxquestions.org/questions/linux-software-2/okular-bookmarks-annotations-lost-for-renamed-pdfs-etc-okular-0-16-2-kde-4-10-2-a-4175460375/)

Geremia 05-01-2013 10:28 PM

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

Diantre 05-02-2013 12:34 AM

Quote:

Originally Posted by Geremia (Post 4943089)
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.

Geremia 05-02-2013 11:34 AM

Quote:

Originally Posted by Diantre (Post 4943131)
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…

Diantre 05-02-2013 02:05 PM

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?

Geremia 05-04-2013 01:51 PM

Quote:

Originally Posted by Diantre (Post 4943589)
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.


All times are GMT -5. The time now is 11:51 PM.