PDF viewer sidekick
A PDF viewer for Visual Studio Code. It opens PDFs from local
folders, Remote SSH, WSL, Dev Containers, virtual workspaces, and other
filesystem providers without copying them to a local path.
Current features
- Default read-only editor for
.pdf files
- Continuous page scrolling with virtualized rendering near the viewport
- PowerPoint-style page overview with resizable, virtualized thumbnails and
keyboard navigation
- Organize Pages: delete and reorder pages in the overview, then save the
result as a new PDF
- Save PDF with Ink: keep slideshow pen and highlighter strokes as annotations
in a copy of the PDF
- Folder preview: a thumbnail gallery of every PDF in a folder, opened from
the Explorer context menu
- Link hover previews: rest the pointer on a PDF link in Markdown, HTML, or any
other text file to see a thumbnail of the PDF
- PowerPoint-style slideshow mode: one page per screen, VS Code chrome hidden,
and slide transitions
- Presenter laser pointer, pen, highlighter, and text labels, with ink kept per slide
- Page tone cycling between normal, inverted, and dimmed for dark themes
- Save the current page as a PNG image
- Previous, next, and direct page navigation
- Full-document text search with snippets, active-result highlighting,
match-case and whole-word modes, progress, and cancellation
- Lazy page thumbnails and PDF outline navigation in a resizable sidebar
- Fit-width, fit-page, preset, and custom zoom
- Current page size shown in millimeters in the toolbar
- Ctrl+wheel zoom with pointer anchoring (Cmd+wheel on macOS)
- Double-click page zoom and Ctrl+0/Ctrl+1 zoom shortcuts
- Clockwise rotation
- Selectable PDF text
- External and in-document links
- Existing PDF annotation appearances
- Password-protected documents
- Per-URI page, zoom, rotation, and sidebar restoration
- External-change notification and reload
- Editor title-bar button to open the current PDF in the OS's default PDF
application
- Light, dark, and high-contrast VS Code themes
- VS Code-native icons, page-loading skeletons, and flicker-free rerendering
PDF contents are processed locally by the bundled PDF.js runtime. The extension
collects no telemetry. Its only network requests download a PDF when you hover
an http or https link to one, which pk.hover.remoteLinks turns off.
Commands
PDF viewer sidekick: Open PDF
PDF viewer sidekick: Open Current PDF in Viewer
PDF viewer sidekick: Go to Page
PDF viewer sidekick: Find in PDF
PDF viewer sidekick: Toggle Navigation Sidebar
PDF viewer sidekick: Toggle Page Overview
PDF viewer sidekick: Zoom In
PDF viewer sidekick: Zoom Out
PDF viewer sidekick: Rotate Clockwise
PDF viewer sidekick: Reload PDF
PDF viewer sidekick: Cycle Page Tone (Normal, Invert, Dim)
PDF viewer sidekick: Save Page as Image
PDF viewer sidekick: Organize Pages (Delete and Reorder)
PDF viewer sidekick: Save PDF with Ink
PDF viewer sidekick: Browse PDFs in Folder
PDF viewer sidekick: Start Slideshow
PDF viewer sidekick: Exit Slideshow
PDF viewer sidekick: Open in PDF App
Folder preview
Right-click a folder in the Explorer and choose
PDF viewer sidekick: Browse PDFs in Folder to open a gallery of cover
thumbnails for every PDF directly inside it. Right-clicking a .pdf previews
the folder that file sits in, and the command palette entry uses the folder of
the PDF you are already viewing.
Each card shows the first page, the file name, the page count, and the file
size. Click a card, or press Space, to view that PDF in the viewer;
Ctrl+click (Cmd+click on macOS) views it beside the gallery and keeps focus
in the gallery. Double-click, or press Enter, to open it in your PDF app.
Arrow keys move between cards. To delete a PDF, right-click its card and
choose Delete Selected PDF, or select it and press Delete; after you
confirm, it moves to the Trash (the Recycle Bin on Windows). Filter by name or resize
the thumbnails with the slider. Covers are rendered only as their cards scroll
into view and the PDF is released immediately afterwards, so a folder of
hundreds of files stays responsive. Files above pk.fileSizeWarningMB are listed but not
rendered, and password-protected PDFs show a lock instead of a cover. The
gallery refreshes itself when PDFs are added to or removed
from the folder. Subfolders are not included.
Link hover previews
Rest the pointer on a link to a PDF in a text editor to see a thumbnail of the
PDF, with its file name, page count, and size, plus a link that opens it in
the viewer. It works in Markdown ([chart](https://github.com/prasertcbs/pdf-sidekick-vsix/blob/HEAD/chart.pdf), [doc](https://github.com/prasertcbs/pdf-sidekick-vsix/blob/HEAD/<my file.pdf>),
and reference definitions), in HTML attributes such as
<a href="./chart.pdf">, and on bare paths and URLs in any other file. The
hover covers the whole link, so resting on its text works too.
- Relative paths resolve against the file containing the link, and a leading
/ resolves against its workspace folder. Files are read through the
workspace filesystem, so Remote SSH, WSL, and virtual workspaces work.
- A
#page=N fragment previews that page instead of the first.
- http and https links are downloaded for the preview, up to
pk.hover.maxRemoteSizeMB. Set pk.hover.remoteLinks to false to only
preview local files.
- Local files above
pk.fileSizeWarningMB are not rendered.
- Previews are cached, so hovering the same link again is instant, and a local
preview refreshes when the PDF changes.
Pages are drawn off the editor's thread by a native renderer, so the
extension ships one package per platform. Set pk.hover.enabled to false
to turn hover previews off.
Slideshow
Press the play button in the viewer toolbar (or run
PDF viewer sidekick: Start Slideshow) to present the PDF one page per screen.
The slideshow starts on the current page, so selecting a thumbnail in Page
Overview first — or pressing Shift+Enter on it — presents from there.
| Key |
Action |
Space, Enter, →, ↓, Page Down |
Next slide |
Backspace, ←, ↑, Page Up |
Previous slide |
Home, End |
First or last slide |
B |
Blank the screen to black; any key resumes |
W |
Blank the screen to white; any key resumes |
L |
Toggle the laser pointer |
Shift+L |
Toggle the laser pointer with a fading tail |
L L (double-tap) |
Switch the laser pointer's fading tail on or off |
P |
Toggle the pen |
Shift+P |
Toggle the fading pen |
P P (double-tap) |
Switch the pen between permanent and fading ink |
H |
Toggle the highlighter |
Shift+H |
Toggle the fading highlighter |
H H (double-tap) |
Switch the highlighter between permanent and fading ink |
T |
Toggle the text label tool |
Shift+T |
Toggle the text label tool with fading labels |
T T (double-tap) |
Switch text labels between permanent and fading |
E |
Erase the ink on this slide |
| Other letters, with a presenter tool armed |
Pick that tool's color (see below) |
Shift + a color letter |
Pick the complement of that letter's color |
Escape |
Put the laser, pen, or highlighter away, then end the slideshow |
Clicking a slide advances it, right-clicking goes back, and the mouse wheel
moves one slide per gesture. A control bar and page counter fade in when the
pointer moves and fade out again while it is still. Each control-bar button
with a letter shortcut shows that letter in its corner.
Pen strokes are stored per slide in page-relative coordinates, so going back to
an annotated slide shows the ink again, and it stays anchored to the same spot
on the page when the window is resized. Ink is kept until the PDF is reloaded
or closed unless you save it (see below). While the pen or highlighter is
armed, clicking draws instead of advancing. Highlighter strokes are translucent
and sit beneath pen ink, so text under them stays readable. Hold Shift while
dragging to draw a straight line from where Shift was pressed; release it to
carry on freehand. Hold Alt while dragging to draw a rectangle from where
Alt was pressed to the pointer; release it to keep the rectangle and carry on
freehand. E erases both, along with any text labels.
With the text label tool (T) armed, click anywhere on the slide and type a
short label; Enter finishes it, Shift+Enter starts a new line, and
Escape cancels. Clicking elsewhere also finishes it, and leaving it empty
removes it. Click a label to edit it again. Labels use the tool's color and one
of four sizes from its palette, stay anchored to their page like ink, and fade
3 seconds after you finish them when armed with Shift+T.
Fading ink, armed with Shift+P or Shift+H (or a Shift-click on the pen or
highlighter button), is for pointing something out without leaving a mark:
each stroke stays for two seconds after you lift the pointer, then fades out
over one more. Double-tapping P or H switches that tool between permanent
and fading ink and leaves it armed: from a permanent pen (or a put-away one) to
a fading pen, and from a fading pen back to a permanent one. While fading ink
is armed, its button's fill fades too. With
reduced motion turned on, strokes vanish at three seconds instead of fading.
To keep the ink, press the save button in the control bar (or run
PDF viewer sidekick: Save PDF with Ink). It writes a copy of the PDF, named
<name>-ink.pdf by default, with every pen and highlighter stroke on every
page as a standard PDF ink annotation, and every text label as a text box
(FreeText) annotation, so Acrobat, Edge, Chrome, and Preview show them and can
still select, move, or delete each one. The highlighter stays translucent. A
label is saved as a high-resolution picture of how it looked, so Thai and any
other script come out exactly as typed, and its text is kept in the
annotation for other viewers' comment lists. Fading ink and labels are left
out. The open PDF is not changed unless
you choose to save over it.
The laser pointer has no tail by default. Double-tap L (or press Shift+L,
or Shift-click its button) for a tail that follows the pointer and fades out
within half a second; double-tap L again to drop it. While the tail is on,
the laser button's fill fades, as it does for fading ink.
Press and hold the laser, pen, or highlighter button in the control bar (or
right-click it) to open that tool's palette. Its top row picks a color from the
eight color-blind-safe Okabe–Ito colors: black, orange, sky blue, bluish green,
yellow, blue, vermillion, and reddish purple. Its bottom row picks one of four
sizes: the laser pointer's diameter, or the pen's or highlighter's stroke
width. Each tool keeps its own color and size until the viewer is closed. Until
one is picked, the laser and pen use the pk.slideshow.penColor setting, the
pen uses pk.slideshow.penWidth, the laser is medium, and the highlighter is a
medium yellow. Ink already drawn keeps the color and width it was drawn in.
While the laser, pen, highlighter, or text tool is armed, a letter key switches
it to a color, the same palette as KPen, in the slideshow and the document
view alike. Hold Shift with the letter for that color's complement (the
opposite hue, at the same saturation and lightness; grays stay as they are).
B and W pick blue and white while a tool is armed, so blank the screen with
. and , then; E still erases, and H, L, P, and T still arm the
tools. With no tool armed, letters do what the table above says.
Q |
W |
R |
Y |
U |
I |
O |
#777777 |
#ffffff |
#d81b60 |
#ffcc00 |
#d45087 |
#3b5bdb |
#ff9900 |
A |
S |
D |
F |
G |
J |
K |
#e69f00 |
#56b4e9 |
#009e73 |
#f0e442 |
#89f336 |
#d55e00 |
#000000 |
Z |
X |
C |
V |
B |
N |
M |
#d7b7e8 |
#8fc9f5 |
#00ffff |
#bfe7b2 |
#0072b2 |
#f6c38b |
#ff00ff |
Presenter letter keys, and . and ,, also work with a keyboard layout that
doesn't type Latin letters, such as Thai: the key in the letter's position on
a US keyboard does the same thing, so there is no need to switch layouts.
The pencil button in the viewer toolbar brings the same control bar to the
document view, without going full screen: previous and next page, the laser
pointer, pen, highlighter, and erase. It fades in when the pointer moves and
out again while it is still, and while it is on, L, Shift+L, P,
Shift+P, H, Shift+H, T, Shift+T, the L, P, H, and T
double-taps, and E work as in a slideshow (E erases the current page).
Escape puts the armed tool away. Ink is drawn on the page under the pointer
and scrolls and zooms with it. It carries into and out of a slideshow and
stays when the bar is turned off. Rotating the pages clears it.
Page tone and page images
The page tone button cycles the rendered page between normal, inverted, and
dimmed, which makes a white page bearable inside a dark theme. The tone is
remembered per PDF alongside page, zoom, and rotation, and it applies to
thumbnails and the Page Overview too.
The camera button saves the current page as a PNG next to the PDF, at twice the
document's natural size. The export renders its own canvas, so the saved image
carries the document's real colors no matter which page tone is on screen, and
it is written through the workspace filesystem so it works over Remote SSH and
in virtual workspaces.
Organizing pages
Press Delete/Reorder pages in the toolbar (or run
PDF viewer sidekick: Organize Pages (Delete and Reorder)). It opens the Page
Overview if you are not already there. While organizing:
| Action |
How |
| Select a page |
Click |
| Add or remove a page from the selection |
Ctrl+click (Cmd+click on macOS) |
| Select a range |
Shift+click |
| Select every page |
Ctrl+A |
| Delete the selection |
Delete or Backspace, or the Delete button |
| Move pages |
Drag them, or Ctrl+arrow keys |
| Undo |
Ctrl+Z, or the Undo button |
| Put everything back |
Reset |
| Clear the selection, then leave |
Escape |
Thumbnails are numbered by their new position; hover one to see its original
page number. Save as PDF… writes a new file beside the original, which is
never modified, and it goes through the workspace filesystem so it works over
Remote SSH and in virtual workspaces. At least one page always stays.
Your changes stay put if you leave organize mode to read a page, but they are
not saved anywhere until you save them: switching to another editor tab
discards them. The saved PDF keeps page content and document information
(title, author, and so on) but not bookmarks or fillable form fields, and
password-protected PDFs cannot be organized.
Settings
pk.defaultZoom
pk.rememberViewState
pk.fileSizeWarningMB
pk.gallery.thumbnailWidth
pk.hover.enabled
pk.hover.thumbnailWidth
pk.hover.remoteLinks
pk.hover.maxRemoteSizeMB
pk.slideshow.transition
pk.slideshow.showPageCounter
pk.slideshow.advanceOnClick
pk.slideshow.wheelAdvance
pk.slideshow.controlsIdleTimeoutMs
pk.slideshow.enterZenMode
pk.slideshow.penColor
pk.slideshow.penWidth
Limitations
Attachments, printing, bookmark editing, and annotation editing are not
implemented. Organize Pages and Save PDF with Ink write a new PDF, so the open
PDF is never modified unless you choose to save over it.
A slideshow hides the window chrome with VS Code's Zen Mode, which also takes
the window full screen unless zenMode.fullScreen is turned off. VS Code
exposes no way to read the current Zen Mode state, so starting a slideshow
while Zen Mode is already on leaves it, and exiting turns it back on; set
pk.slideshow.enterZenMode to false to leave the window chrome alone.
Reloading the window during a slideshow may leave Zen Mode active — run
PDF viewer sidekick: Exit Slideshow or toggle Zen Mode to recover. The
slideshow is not part of the saved view state, so it never resumes on its own
when a PDF is reopened, and it ends when its editor tab is hidden or closed.
Development
npm install
npm run typecheck
npm test
npm run build
Press F5 in VS Code to launch an Extension Development Host. Run
npm run package to produce a VSIX.
PDF rendering is provided by Mozilla PDF.js under the Apache-2.0 license. Its
license is included in packaged builds as dist/PDFJS-LICENSE.