6

I am trying to figure out where okular is saving annotations for pdf files. According to this answer they should be in ~/.kde/share/apps/okular/docdata but there is no files in that folder. But still when I open the pdf file, the annotations are there. If I copy the pdf file to another file and open the other file, the annotations are gone, so they cannot be saved in the file itself either. Any suggestions?

Håkon Hægland
  • 3,973
  • 12
  • 46
  • 80
  • According to https://okular.kde.org/faq.php#addedannotationsinpdf "By default, Okular saves annotations in the local data directory for each user." (No, I'm not sure where that is located...) "Since KDE 4.9, it's optionally possible to store them directly in a PDF file by choosing "File -> Save As...", so they can be seen in other PDF viewers." There's also a 'document archiving' feature to preserve annotations that's explained at that link. Sorry I'm not more helpful with a specific directory -- maybe someone else knows? – Nick Weinberg Aug 03 '17 at 18:30
  • Thanks for the input. Yes I am also aware that they can be saved in the pdf file. But I am now interested in the case where you don't save them in the pdf file and where this "local directory for each user" is located? – Håkon Hægland Aug 03 '17 at 18:33
  • That's an excellent question that I hope someone else can help answer for you! – Nick Weinberg Aug 03 '17 at 18:34
  • I'm using Kubuntu 16.04 with the kubuntu-backports ppa and Okular is v. 0.25.0. I added a pop-up note to an existing pdf file and found ~/.kde/share/apps/okular/docdata/test.pdf.xml to contain the text of the pop-up note along with other formatting information re. the note. Which version of Kubuntu are you on? – DK Bose Aug 04 '17 at 01:22
  • Hi @DKBose. Thanks for testing. I am using Ubuntu 17.04 (so I am not using Kubuntu) and Okular version 1.0.3. – Håkon Hægland Aug 04 '17 at 03:31

3 Answers3

5

I'm on 18.04, and using okular 1.3.3, I have just annotated several dozen comments into a 500+ page pdf. I note that in ~/.local/share/okular/docdata, there are several .xml files named filesizeinbytes.pdftitle.pdf.xml

I don't see any of those annotations. Also, I did do a 'Save' 4 times, in an effort to make sure my annotations didn't disappear, and as a result, I have 4 different .xml files, each about 1000 bytes (by the numbers at the beginning of the .xml file's name) bigger than the last.

So, I checked the contents of the PDF file and there they are!

The contents of the text associated with the annotations are encoded in what looks like UTF-16, with a null between each character, so it's useless looking for the text inside the pdf. But using grep -a 'Annot ' I can see each of the annotations in coded format. This storage method makes automated annotation pretty difficult, but, oh well!

And, on the bright side, since the annotations are now natively included in the pdf, ANY pdf viewer (besides okular) can be used, and will see the annotations.

Sebastian Stark
  • 6,122
  • 19
  • 48
user60381
  • 119
  • 1
    Please edit you answer and incorporate the comments above where you found the solution into your answer. Then the next user does not have to check the comments to find the solution. Thanks! – Håkon Hægland May 23 '18 at 05:22
  • Isn't the question "where are the annotations being stored?", and aren't I giving a precise answer for Ubuntu 18.04, okular 1.3.3? – user60381 May 23 '18 at 18:57
  • this should be the accepted answer – Homero Esmeraldo Jun 18 '19 at 18:26
  • https://github.com/politza/pdf-tools/issues/161 the annotations do not display in Chrome, unless you print them to the pdf (which makes them uneditable). – Homero Esmeraldo Jun 18 '19 at 18:44
4

Previously, all okular data was stored in ~/.kde/share/apps/okular. It appears that it has finally been moved to ~/.local/share/okular where it belongs. Try looking there. You may also have to copy your bookmarks into that directory from the old one so that they work.

Peter
  • 64
1

Ubuntu 22.04.3 LTS Okular 23.08.4 ~/snap/okular/146/.local/share/okular/

Sometimes for a new Ubuntu and newly downloaded Okular you have to create a bookmark from a pdf before docdata folder shows up.