Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PDF Viewer & HighlighterNew to Visual Studio Code? Get it now.
PDF Viewer & Highlighter

PDF Viewer & Highlighter

pupydodo

|
1 install
| (0) | Free
A fork of vscode-pdf by tomoki1207, enhanced with text highlighting and editable comments. Save annotations directly to your PDF with Ctrl+S, without reloading the document.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PDF Viewer & Highlighter

A fork of vscode-pdf by tomoki1207, enhanced with text highlighting and editable comments. Save annotations directly to your PDF with Ctrl+S, without reloading the document.

This fork is maintained and published by pupydodo.

Highlight selected text

Requires VS Code 1.72 or newer.

  1. Open a PDF with Pdf Preview and use the text selection cursor.
  2. Select text, then right-click the selection and choose Highlight (高亮 in Chinese).
  3. The selected text is highlighted in yellow immediately. Changes stay in memory and the editor is marked as modified; the PDF is not reloaded.
  4. Press Ctrl+S (Cmd+S on macOS) to write the highlights to the PDF.

Saving also keeps the current page canvases, zoom, rotation, and scroll position. Ctrl+Z / Ctrl+Y (macOS: Cmd+Z / Cmd+Shift+Z) undo and redo highlights, including edits made before the last save. Closing a modified editor uses VS Code's normal save/discard handling. Save As, Revert File, and recovery of unsaved changes after restarting VS Code are supported.

The editor follows VS Code's Files: Auto Save setting, like a code editor. If you want to save only with Ctrl+S, leave Auto Save off.

Saved highlights are standard PDF annotations: they remain after reopening the file and are visible in other PDF readers. Partial words, multiple lines, and selections across rendered pages are supported, including when zoomed or rotated. Existing text, links, and annotations are retained.

The PDF must be writable and unencrypted. Scanned image-only PDFs need OCR before text can be selected.

Remove highlights

Click a highlighted area, then choose Remove highlight (取消高亮 in Chinese). This removes the highlight and its comment, including any unapplied comment draft. It works for new highlights and annotations already in the PDF.

The removal is staged until Ctrl+S (Cmd+S on macOS), or Auto Save. Ctrl+Z restores the highlight and its applied comment, even after saving. Grouped highlights spanning multiple pages are removed together. The viewer updates the affected pages without reloading the PDF.

Edit highlight comments

Click a highlighted area (without dragging a text selection) to open its comment editor. This works for new highlights and highlights already saved in the PDF.

  • Enter a multiline comment and choose Apply or press Ctrl+Enter to stage the change. Ctrl+S saves it to the PDF; pressing Ctrl+S inside the comment editor also applies the current draft before saving.
  • Cancel or Escape discards the current unapplied draft.
  • Clear the comment and apply it to remove the comment while keeping the highlight.
  • Applied changes support the same undo/redo, Save As, and backup recovery as highlights. On macOS, use Cmd in place of Ctrl.

Comments use the PDF annotation's standard text content and remain editable after reopening, including in other PDF readers. Cross-page highlights created by this version share a comment across their pages. Editing and saving do not reload the PDF.

Development

npm ci
npm test
npm run lint
npm run package

Press F5 to launch the extension in a development window. To test the browser selection and save flow, install Chromium for Playwright and run:

npx playwright-core install chromium
npm run test:browser

Alternatively set PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH to an existing Chromium executable. The browser tests exercise the real PDF.js viewer with a simulated VS Code message bridge; the native VS Code menu can be checked in the F5 window.

screenshot

Contribute

Upgrade PDF.js

  1. Download latest Prebuilt(older browsers).
  2. Extract the ZIP file.
  3. Overwrite ./lib/* by extracted directories.
    • If lib/web/viewer.html has changes, apply these changes to HTML template at pdfPreview.ts.
  4. To not use sample pdf.
  • Remove sample pdf called compressed.tracemonkey-pldi-09.pdf.
  • Remove code about using sample pdf from lib/web/viewer.js.
    defaultUrl: {
      value: "", // "compressed.tracemonkey-pldi-09.pdf"
      kind: OptionKind.VIEWER
    },
    

Change log

See CHANGELOG.md.

License

Please see LICENSE

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft