[Plugin] MarginFit — smart PDF margin fitting and page navigation for Zotero

edited 3 days ago
PDFs often have large or uneven margins, making the actual text smaller than necessary. I made this MarginFit plugin to improve the PDF reading experience in Zotero.

The plugin adds three buttons to the PDF reader toolbar: Fit Width, Fit Height, and Detect Margins. Note that the original Fit Width button will be replaced.

It provides three main features:

- Smart margin fitting: Automatically detects the actual content boundaries and enlarges the content to better fill the reading window.
- Fit Width / Fit Height: Switch between width and height fitting with one click. Click the selected mode again to turn it off.
- Content-aware page navigation: Use Page Down / Page Up to jump between pages aligned to their content, while keeping normal scrolling and fine adjustments within each page.

The original PDF files are not modified.

Usage: Download the `.xpi`, install it through Zotero's plugin manager, and open a PDF to use the new toolbar buttons.

Tested on Windows / Zotero 10.0.6. Other platforms have not been tested.

---

- [Download / 下载插件](https://github.com/SeptYagu/zotero-margin-fit/releases/latest)
- [Source / 项目仓库](https://github.com/SeptYagu/zotero-margin-fit)

---

Author: Septyagu

Feedback is welcome! / 欢迎反馈使用体验!

很多 PDF 文献的页边距很大,或者不同页面的留白不一致,导致正文显示得比较小。所以我做了这个 Zotero 插件:MarginFit。

插件在 PDF 阅读器工具栏中提供三个按钮:适合宽度、适合高度、识别边界。替换了原版适应宽度按钮。

主要功能:

- 智能去白边: 自动识别实际内容边界,放大正文,减少多余留白。
- 智能适合宽度/高度: 一键切换两种阅读方式,再次点击当前模式即可关闭。
- 智能整页翻页: 使用 Page Down / Page Up 跳转到上一页或下一页的正文位置,同时保留页内自由滚动和微调。

插件不会修改原始 PDF 文件。

用法: 下载 `.xpi` 文件,在 Zotero 插件管理器中安装,打开 PDF 后即可使用工具栏中的新按钮。

已在 Windows / Zotero 10.0.6 测试。

  • This plugin looks great! I've been working on a plugin with similar aims here: https://github.com/dawaltconley/zotero-center-pdf I don't have a ton of time to devote to dev at the moment but would be happy to try and combine efforts if it's helpful.

    One thing you may want to look into: it looks like your plugin waits for Zotero to navigate to the next page before realigning the view, resulting in a noticeable stagger/delay. I got around this by monkeypatching the functions Zotero uses to navigate to the next/previous page, so that the realignment happens before the DOM gets redrawn. Feel free to copy that code if it's useful.
  • @dawaltconley Thanks for sharing your project!

    I took a look at your code, and I really like your approach to intercepting Zotero's navigation functions. The delay you noticed is definitely something I'd like to improve.

    MarginFit currently has two slightly different reading modes. Fit Height is designed for page-by-page navigation, so your approach looks particularly promising there. Fit Width, on the other hand, needs to preserve continuous scrolling, especially when two pages are visible at once. I'm also exploring using the detected content boundaries to make transitions between pages smoother.

    I'm planning to experiment with your navigation approach for Fit Height while keeping the existing margin detection and caching system. I'd be happy to exchange ideas and collaborate where our projects overlap!

    Thanks again for the suggestion and for offering to help!
Sign In or Register to comment.