Link to open PDF at a specific page

2020-11-14 Thread Georges Ko
Hi,

I'd like to open a PDF file to a specific page from a link, using the
default PDF viewer in Windows (same as w32-shell-execute "open"), which
opens a browser.

With a browser, I can open it with this HTML link:

  Page 4

This link as an Org mode link doesn't work:

  file:///c:/a/b/c/file.pdf#page=4

as "#page=4" is interpreted as part of the filename by w32-shell-execute.

If I modify org-file-apps for PDF to:

("\\.pdf::\\([0-9]+\\)\\'" . "browser file:///%s#page=%1")

and if the Org link is:

  file:///c:/a/b/c/file.pdf::4

it doesn't work because the argument passed to browser is:

  file:///"c:/a/b/c/file.pdf"#page=4

A quick workaround is to modify org-open-file by removing
shell-quote-argument, from:

  (shell-quote-argument (convert-standard-filename file))

to

  (convert-standard-filename file)

to get the following string, which correctly opens page 4.

  "file:///c:/a/b/c/file.pdf#page=4"

If I export the file as HTML, it is output as:

  ...

so I modified org-html-link from:

  (concat raw-path
  "#"
  (org-publish-resolve-external-link option path t))

to

  (concat raw-path
  "#"
  (let ((r (org-publish-resolve-external-link option path t)))
(or (and (string= r "MissingReference")
 (string-match "\\.pdf\\'" path)
 (string-match "[0-9]+" option)
 (format "page=%s" option))
r)))

which generates the wanted HTML link:

  ...

Is there any way less quick & dirty to achieve this?

Thanks!






Re: [O] Convert from date to week number, howto?

2012-02-03 Thread Georges Ko
Jambunathan K kjambunat...@gmail.com writes:

 I sometimes have to convert from a date to a week number, 

 Try this. 

 (org-odt-format-date 2011-12-31 Sat %U)
 (org-odt-format-date [2011-12-24 Sat] %U)

 You can steal the implementation. The functions have nothing to do with
 org-odt, btw.

Another way to get the week of the year is:

(require 'calendar)
(require 'cal-iso)

(car
  (calendar-iso-from-absolute
(calendar-absolute-from-gregorian 
  (list month day year
-- 
 Georges Ko g...@gko.net  2012-02-03