Open multiple pdfs in Okular from command line

command lineokular

I have Okular configured that when it's already running and I open a pdf from the command line, it should open the new file as a new tab in Okular.

However, if this new file is in another directory than the other one, Okular fails to open the document and only displays an empty tab with the file name and the error message

Could not open /path/to/bar.pdf

Short example:

okular foo.pdf &
okular bar.pdf

works the way I would expect it to.

okular foo.pdf &
cd ..
okular foobar.pdf

would only open foo.pdf correctly, but fail to display foobar.pdf.

The Okular version I'm working with is 0.19.3.

//Edit:
Maybe I should mention: If I open the same combination of files from a file manager (in my case Dolphin), Okular behaves as expected. I only have issues using the command line.

//Edit:
I just tried the same thing on another computer using Okular 0.23.2. It worked fine, so I guess the bug has been taken care of already.

Best Answer

Workaround: Open additional pdf files either using the absolute path names or relative path names to the initial pdf file.

So for example

okular foo.pdf &
okular ../foobar.pdf

and

okular foo.pdf &
okular /the/complete/absolute/path/to/foobar.pdf

both work.

//Update:

To automate the workaround, this function can be added to ~/.bashrc. It simply reads the file's absolute name and passes it to okular via stdin.

function okular
{
  command readlink -f $1 | xargs okular
}
Related Question