15

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?

11

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.

3

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.

  • Pop-up notes are not clickable hence you can use them. – rbaleksandar Jul 30 '17 at 17:12
2

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

  • 3
    That'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. – Bichoy Apr 7 '13 at 16:30
1

Just use file > print > printer name: print to file (PDF). Output file goes to your home by default. Your annotation should be there.

  • 2
    This 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. – theindigamer Feb 25 '15 at 16:11
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.