weirdNox / org-noter

Emacs document annotator, using Org-mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow custom default pdf-tools 'fit' code when opening a PDF

gcoladon opened this issue · comments

commented

I couldn't figure out a way to do this by reading the docs or the source, but when a frame opens up the PDF and the notes file, I would like to PDF to be "fit to [W]idth", and others may prefer it be "fit to [H]eight", or "fit to [P]age". The default could be "0", which is my estimate for what is currently the default behavior.

I am no expert in elisp, but it this sounded not too difficult to do, and would be accepted as a PR, I could try writing this code myself.

commented

would inside org-noter--setup-windows be the right place to (setq pdf-view-display-size 'fit-width)?

I guess this feature would need to support the other PDF viewing libraries too, but I don't yet know if they even support such a feature.

Use this configuration:

  (use-package org-noter
    :after (:any org pdf-view)
    :config
    (setq org-noter-always-create-frame nil
          org-noter-auto-save-last-location t)
    (defun org-noter-init-pdf-view ()
      (pdf-view-fit-width-to-window)
      (pdf-view-auto-slice-minor-mode))
    (add-hook 'pdf-view-mode-hook 'org-noter-init-pdf-view))

Remove (pdf-view-auto-slice-minor-mode) if you do not want the margins to be cropped automatically.

commented

@auroranil hey thanks, I didn't think of doing it that way. In fact I trimmed down your snippet to just this, and it still has the desired effect:

(use-package org-noter
    :after pdf-view
    :config
    (add-hook 'pdf-view-mode-hook 'pdf-view-fit-width-to-window))

Closing the issue as resolved.