Bug 226718 - Make Forward Search for pdf work with okular
Summary: Make Forward Search for pdf work with okular
Status: RESOLVED FIXED
Alias: None
Product: kile
Classification: Applications
Component: general (show other bugs)
Version: 2.0.84
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Michel Ludwig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-13 20:18 UTC by Christian Trippe
Modified: 2010-03-05 18:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch which allows forward search for pdf for me (3.62 KB, patch)
2010-02-13 20:21 UTC, Christian Trippe
Details
example document for pdf fowars search (113.01 KB, application/x-compressed-tar)
2010-02-23 08:59 UTC, Christian Trippe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Trippe 2010-02-13 20:18:33 UTC
Version:           2.0.84 (using 4.4.00 (KDE 4.4.0) "release 222", KDE:KDE4:Factory:Desktop / openSUSE_11.2)
Compiler:          gcc
OS:                Linux (i686) release 2.6.31.12-0.1-default

With KDE 4.4 okular does support Forward Search with pdfs when using 'pdflatex -synctex=1'
However at the moment it is not possible to configure a tool in kile which allows the forward search with okular.

The reason is the following:

For forward search with synctex, Okular expects the following call:
okular --unique target.pdf#src:<line number>source.tex

where target.pdf and source.tex may include relative or absolute paths (eg. 
"okular --unique subdirectory/target.pdf ..."

However, Kile is configured so as to call:
okular --unique file:/absolute/path/to/target.pdf#src:<line number> 
./relative/path/to/source.tex

There are two things wrong with this.  First, there is a space after the line 
number and before the source information.  And second, the path to the source 
file begins with a "./", which Okular does not seem to be able to parse.  
Additionally, the prefix "file:/" is unnecessary, but Okular doesn't seem to 
mind.

The attached patch changes the relative path to the tex file to the absolute path and removes the space, as this seems to be no longer needed, as the absolute path should not start with a number.

In addition it creates several tools
PDFLatex/Synctex
ForwardPDF
QuickBuild/PDFLatex+ForwardPDF

and removes
PDFLatex/Modern
once as this existed twice before in the correspondig file.

I have tested that Forward Search works now for pdfs and still works for dvi files.

However there are to my knowledge two things to be taken care of which are not implemented so far
- The tools which are created are not added automatically, but only for a new user or if one reset the configured tools to the default ones
- Forward Search for pdf works only for okular from KDE 4.4 on, there is no check at the moment for this as it is down for dvi for okular for KDE < 4.3

If you think the patch is the correct approach, I can try to look into these issues.
Comment 1 Christian Trippe 2010-02-13 20:21:04 UTC
Created attachment 40748 [details]
patch which allows forward search for pdf for me
Comment 2 Michel Ludwig 2010-02-22 22:37:14 UTC
Unfortunately, I'm unable to create a PDF with Synctex information easily. Could you maybe attach one?

Also, it seems that Okular needs different input parameters for ForwardDVI/ForwardPDF, which is something that should be addressed in Okular in the long run, I think.
Comment 3 Christian Trippe 2010-02-23 08:58:29 UTC
(In reply to comment #2)
> Unfortunately, I'm unable to create a PDF with Synctex information easily.
> Could you maybe attach one?

The synctex information is not in the pdf itself, but in the document.synctex.gz file which is created when running 'pdflatex -synctex=1 document.tex'

I will attach a tex-file with the correspondent synctex.gz and pdf file.

> 
> Also, it seems that Okular needs different input parameters for
> ForwardDVI/ForwardPDF, which is something that should be addressed in Okular in
> the long run, I think.

It does not really need different input parameters from what I can tell. Both work with okular test.(dvi|pdf)#src:<line no.>test.tex

It also works if you use absolute pathes for your files or relative pathes without './'. Only when you use relative pathes with './' this works with ForwardDVI but not with ForwardPDF.

I can also report this as bug/wish for okular if you think it should be fixed in okular.
Comment 4 Christian Trippe 2010-02-23 08:59:31 UTC
Created attachment 41028 [details]
example document for pdf fowars search
Comment 5 Michel Ludwig 2010-02-24 23:34:46 UTC
(In reply to comment #4)
> Created an attachment (id=41028) [details]
> example document for pdf fowars search

Thanks for that. I've now committed a slightly modified version of your patch (revision 1095722).

I think it would be good to report this as well to the Okular people as these differences between DVI/PDF forward search are probably not intended.
Comment 6 Christian Trippe 2010-03-05 18:35:41 UTC
(In reply to comment #5)
> 
> I think it would be good to report this as well to the Okular people as these
> differences between DVI/PDF forward search are probably not intended.

Just for reference the bug against okular is https://bugs.kde.org/show_bug.cgi?id=228427