Skip to content

For developers

Ryota Ushio edited this page Feb 3, 2024 · 11 revisions

PDF++ exposes the plugin (PDFPlus) instance as the pdfPlus global variable. It has several methods to interact from the dev console:

  • getPDFDocument: get the reference to PDF.js's PDFDocumentProxy object
  • getPage: get the reference to PDF.js's PDFPageProxy object
  • getPDFView: get Obsidian's native PDF view
  • getPDFViewer: get PDFViewer instance (see typings.d.ts)
  • getPDFViewerChild: get PDFViewerChild instance (see typings.d.ts)
  • getObsidianViewer: get ObsidianViewer instance (see typings.d.ts)
  • getRawPDFViewer: get RawPDFViewer instance (see typings.d.ts)
  • getToolbar: get PDFToolbar instance (see typings.d.ts)

Tips

Get PDF.js AnnotationElement instance from a page number & an annotation ID

// in the dev console
const pageNumber = 2 // 1-based
const annotationId = '1251R' // the string you get when copying a link to the annotation
const annot = pdfPlus.getPDFViewerChild().getPage(pageNumber).annotationLayer.annotationLayer.getAnnotation(annotationId);
console.log(annot)
console.log(annot.data)

Resources