PDF custom viewport mode and adaptive DPI

PDF custom viewport mode

As we know, many PDF documents are made for printing. This means they have some characteristics:

  • wide margin
  • different margin for odd/even page
  • two columns layout for many academic papers

These characteristics make it hard to read on-screen - you have to zoom in and scroll repeatedly. Here I would like to propose a custom viewport mode, where “viewports” instead of “raw pages” are displayed in the PDF viewer.

A viewport is a rectangle area of a PDF page, defined by left, top, width, height, page_id and sort_key. Users can create viewports by:

  • manually select a rectangle like the current “Area highlight” feature and specify a sort_key.
  • Appy a viewport to all/odd/even pages, respectively.
  • They can also remove all viewports.

Once the viewports are created, and viewport mode is toggled. The viewports will be displayed in the order of first sorting by raw pages, then sorting by sort_key.

For example, for a two-column academic paper, a user could create two viewports for each column and applied them to all pages. Then, with the custom viewport mode, the document becomes linear. The user only needs to scroll vertically instead of the “scroll down -> scroll right -> scroll up -> scroll down -> scroll left” loops.

FYI, the free PDF reader Xodo has a similar feature, although they can only work on cropping margins, i.e. they have one and only one viewport for each raw page.

Adaptive DPI

This feature is relatively simple and orthogonal to the viewport feature. The current DPI setting for pdf.js seems to be constant, which would lead to the blurring of the text when zooming in.


left: Logseq; right: other PDF viewer

If the DPI can be adaptively adjusted as zooming in and out, this should be solved.

Thanks.