weirdNox / org-noter

Emacs document annotator, using Org-mode
GNU General Public License v3.0
1.08k stars 101 forks source link

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

Closed gcoladon closed 3 years ago

gcoladon commented 3 years ago

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.

gcoladon commented 3 years ago

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.

auroranil commented 3 years ago

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.

gcoladon commented 3 years ago

@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.