Customise Okular to modify highlight tool properties

I am using Okular as my pdf reader on Linux. I want to know how I can modify the color of the highlight permanently. I know I can modify the saturation of the color used by highlight tool by right clicking on the highlight selection and making the desired modifications. However, those are applicable only to the current selection.

How can I set okular to maintain those settings for every highlight in the file(and still allow customising at specific positions) and also maintain them after the file is closed [and opened later .i.e. the settings are not lost]


Solution 1:

I wanted to permanently set the highlighters to a few colors and do away with the green line and polygon stuff. It turns out you can modify what highlighters are available by modifying the tools.xml file. For me (Okular 0.16.3 from official repository on Ubuntu 13.04), this is located at /usr/share/kde4/apps/okular. You should be able to divine this by running kde4-config --path data and appending okular to the last path (but see update below).

In there, you'll see things like

<tool id="7" name="Stamp" pixmap="tool-stamp-okular">
    <tooltip>Put a stamp symbol</tooltip>
    <engine type="PickPoint" hoverIcon="okular" size="64" block="true">
        <annotation type="Stamp" icon="okular"/>
    </engine>
    <shortcut>7</shortcut>
</tool>

If you replace it to look like the yellow highlighter's block, you'll get a similar highlighter. In my case:

<tool id="7" name="Magenta Highlighter" pixmap="tool-color-magenta">
    <tooltip>Magenta Highlight</tooltip>
    <engine type="TextSelector" color="#FF99FF">
        <annotation type="Highlight" color="#FF99FF" />
    </engine>
    <shortcut>7</shortcut>
</tool>

The tool-color-magenta pixmap is stored in /usr/share/kde4/apps/okular/pics and you can put a png there.

So now my review toolbar looks like this:

enter image description here

I needed to sudo to modify these files.

Update: following the periodic software update window in ubuntu, I have upgraded Okular to 0.16.4, which restored the default tools.xml. It looks like if instead you copy or symlink your customized files to the kde apps okular path under your $HOME (in my case, $HOME/.kde/share/apps/okular), it should take precedence over the /usr/share/... ones and save you some trouble.

Solution 2:

In newer versions of Okular (the mine are Okular 1.9.3, Qt: 5.13.2, KDE Frameworks: 5.70.0), it is possible:

  • to configure the tools via a UI
  • to carry a configuration from one installation to another

If you do not personalize your tools, Okular uses by default a system-wide configuration file (for instance, that is /usr/share/okular/tools.xml in my Fedora 31).

In order to configure the tools via UI, go to Settings > Configure Okular... > Annotations.

The personalized tool settings are stored as the value associated with the AnnotationTools key (see the [Reviews] section) of the $HOME/.config/okularpartrc file. These settings override the default system-wide ones.