|
From: | Joe Riel |
Subject: | Re: [Orgmode] Specify page number in hyperlink [to pdf] |
Date: | Fri, 30 Apr 2010 07:28:52 -0700 |
User-agent: | Thunderbird 2.0.0.24 (X11/20100317) |
Nick Dokos wrote:
Joe Riel <address@hidden> wrote:Jan Böcker wrote:On 28.04.2010 20:30, Joe Riel wrote:The hyperlink syntax allows specifying a line number, however, that doesn't do anything (other than force the document to be opened inside of emacs) with a non-text file (say a pdf). Is therea an extension to allow specifying a page number so that a link to a pdf is opened at the specified page?There is in the current git version, its not yet documented though. Add an entry to the variable org-file-apps like this: ("\\.pdf::\\([0-9]+\\)\\'" . "evince \"%s\" -p %1") Or as seen in the customize interface: Extension: \.pdf::\([0-9]+\)\' Command: evince "%s" -p %1 The subexpression \([0-9]+\) in the regex captures the page number, which replaces the %1 in the command string. (This example assumes you want to open your PDFs with evince, which accepts a page number after the -p option.) You can then reference a specific page of a PDF like this: [[file:/path/to/document.pdf::42]] I had planned to document this yesterday, but unfortunately spent the better part of the day recovering from a cold. I will send a patch describing how this works, when exactly the new behaviour kicks in and the implications for backwards compatibility as soon as I find time to describe it compactly enough to fit into the docstring. HTH, JanA related question; can this extension be used with link abbreviations? I tried #+LINK: sample file:/home/joe/sample.pdf with [[sample::3]] but that does not work.This happens in org-link-expand-abbrev: it splits sample::3 into "sample" and "3", looks up "sample" in org-link-abbrev-alist and performs the replacement, then returns the concatenation of that with the "3" part, thereby eliminating the "::" marker that would trigger the further processing necessary to open the pdf file at the given page. You could try #+LINK: sample file:/home/joe/sample.pdf::%s This will work with the [[sample::3]] link, but not with [[sample]].
That is fine, though I'll apply the patch. There does appear to be another bug, or my misunderstanding. That is, even without the link, [[file:/home/joe/sample.pdf]] does not work properly. That is, clicking on it (mouse 1)opens the pdf inside emacs rather than in a standalone pdf reader. Previously
that wasn't the case (if memory serves). Using [[file:/home/joe/sample.pdf::1]] for the link opens it in a standalone reader. Joe
[Prev in Thread] | Current Thread | [Next in Thread] |