Storing Okular PDF annotations and metadata in the PDF itself
Solution 1
This information is documented in the okular documentation.
As alxs mentioned, a method supported for a while now is to save the PDF document as an archive, which creates a .okular
file. Saving the annotations directly in the PDF is quite recent, and from the documentation this option is only available from version 0.15. With such a recent version, using Save As
and saving as a PDF stores the annotations as well. Note as well that, as mentioned in the documentation, this also requires a recent version of poppler
.
A problem you might have, however, is that a document saved as an archive cannot be currently saved back as a pdf. Therefore, if you already made your annotations, and want to use a newer version of okular
to save these in the PDF, it may get tricky. If you just update your version of okular, this may work, since it will use the same ~/.kde/share/apps/okular/docdata
folder. However if you want to use a newer version of okular on another system, you should transfer the PDF and the corresponding metadata file separately.
Solution 2
After making any annotation using Okular,
Go the the Print option (in File Menu or Ctrl+P) and then in the Name option change the value to Print to File(PDF) and in the Output file option give the path of the output file you need.
Voila, your annotations are now a part of your new PDF.
Solution 3
From okular faq:
How can I annotate a document and send it to a friend/colleague/etc?
Since KDE 4.2, Okular has the "document archiving" feature. This is an Okular-specific format for carrying the document plus various metadata related to it (currently only annotations). You can save a "document archive" from the open document by choosing "File -> Export As -> Document Archive". To open an Okular document archive, just open it with Okular as it would be eg a PDF document.
http://forum.kde.org/viewtopic.php?f=20&t=107182#p247428
Solution 4
Current version of Okular allows one to save the PDF with the annotations by going into File -> Save As.
However, I wanted something automated. So, I created an Autokey script so that whenever I close my PDF, the annotations are automatically saved in the PDF itself. Note that this script will save your PDF overwriting the original PDF.
The Autokey Script
First, you will need to install autokey-gtk
and xdotool
first:
sudo apt-get install autokey-gtk xdotool
Now, in autokey, go to New -> Script. Add the following code to your new script:
#This is used to save PDF in okular so that the annotations persist in the PDF file itself
#We have to use to `xdotool` to bring the dialogs back into focus, otherwise they are losing focus
import subprocess
keyboard.send_keys("<ctrl>+<shift>+s")
time.sleep(0.4)
subprocess.call(["xdotool", "windowfocus", "`xdotool getwindowfocus`"])
time.sleep(0.1)
keyboard.send_key("<enter>")
time.sleep(0.1)
subprocess.call(["xdotool", "windowfocus", "`xdotool getwindowfocus`"])
time.sleep(0.1)
keyboard.send_key("<tab>")
time.sleep(0.1)
keyboard.send_key("<enter>")
time.sleep(0.1)
subprocess.call(["xdotool", "windowfocus", "`xdotool getwindowfocus`"])
time.sleep(0.5)
keyboard.send_keys("<ctrl>+q") #Quit Finally
You can now assign a window filter and hotkey to this script. In window filter, add .*okular.*
. And in hotkey, I've used <ctrl>+s
. You could use anything else that you prefer.
So, now whenever I have to quit okular, I use CtrlS, and okular quits after saving my pdf.
Solution 5
Just use file > print > printer name: print to file (PDF)
. Output file goes to your home by default. Your annotation should be there.
Related videos on Youtube
Comments
-
Bichoy almost 2 years
The PDF viewer Okular (part of KDE desktop) has lots of nice features and supports lots of file formats. One of the things I like about it is the comments and annotations. Unfortunately, all of the comments and metadata (like last viewed page) get stored locally in: ~/.kde/share/apps/okular/docdata
Is there any way to make Okular store them in the PDF itself?
-
naught101 over 10 years
-
Dirk about 4 yearsThis question is obsolete, as okular stores the annotations by default in the original PDF file (as of version 1.6.2, but I think the transition has happened earlier yet).
-
-
Bichoy about 11 yearsThat's good for transferring to Okular users. I want to send the annotated document to a generic user. Someone who may be using whichever operating system and viewing the PDF with his favorite viewer.
-
typesanitizer over 9 yearsThis does not give the most desirable result. Example: I tried underlining and
print to PDF
. While the underline is preserved, the page which has the underline is saved like an image (you can't select the text) but the pages which don't have any annotations permit selecting text. -
rbaleksandar almost 7 yearsPop-up notes are not clickable hence you can use them.
-
Ganton over 3 yearsThe comments to another answer apply there
-
Ganton over 3 yearsAbout "This does not give the most desirable result [...] you can't select the text": It's solved if another method is used