Skip to content

Reviewing Obsidian's native PDF viewer

Ryota Ushio edited this page Feb 6, 2024 · 2 revisions

Obsidian v1.3 introduced a brand new PDF viewer. Later, PDF deep linking (i.e. link to a selection or an annotation) was implemented in v1.3.7.

Despite the built-in viewer's awesome capability, its details have not been documented anywhere.

Deep linking syntax

Link to file

[[file.pdf]], as always.

Link to page

[[file.pdf#page=<PAGE>]] will link to the <PAGE>-th page of file.pdf. Here, <PAGE> is a 1-based page number, which indicates how many pages the page is in the entire PDF document. It can be different from the page label printed in the document content.

You can copy this link by right-clicking a thumbnail image shown in the PDF sidebar.

Link to selection

[[file.pdf#page=<PAGE>&selection=<BEGIN_INDEX>,<BEGIN_OFFSET>,<END_INDEX>,<END_OFFSET>]] is a link to a text selection, which is specified by the page number <PAGE> and the text range <BEGIN_INDEX>, <BEGIN_OFFSET>, <END_INDEX>, <END_OFFSET>.

  • <BEGIN_INDEX> is the index of the text content item that contains the beginning of the text selection.
  • <BEGIN_OFFSET> is the position of the beginning of the text selection within the text content item.
  • <END_INDEX> and <END_OFFSET> indicate the ending position of the text selection similarly to <BEGIN_INDEX> and <BEGIN_OFFSET>.

You can copy this link by right-clicking a text selection in a PDF viewer.

Link to annotation

Each object (annotation, page, ...) in a PDF document has a unique ID. The [[file.pdf#page=<PAGE>&annotation=<ID>]] syntax links to an annotation with ID <ID> contained in page <PAGE>.

You can copy this link by right-clicking an annotation (e.g. highlight, underline, link, etc) in a PDF viewer.

Link to position

[[file.pdf#page=<PAGE>&offset=<LEFT>,<TOP>,<ZOOM>]]

See the comment I added here: https://github.com/RyotaUshio/obsidian-pdf-plus/blob/552bf4ea3f8e6744030557b599eb64711b1266d7/src/api/index.ts#L186-L202

You can copy this link by right-clicking an item in the PDF outline shown in the PDF sidebar.