nLabs Document Viewer
Preview PDF, Word, Excel and CSV documents without leaving VS Code.
Built on a single rule: zero runtime dependencies. No PDF.js, no SheetJS, no
docx-preview - every parser in this extension is written from scratch on top of
Node's own zlib and crypto. Nothing is downloaded, nothing is uploaded, and
the webview has no network access at all.
| Format |
Extensions |
What you get |
| PDF |
.pdf |
Text with on-page positions, embedded images, metadata, bookmarks |
| Word |
.docx .dotx .docm |
Headings, lists, tables, formatting, embedded images |
| Excel |
.xlsx .xlsm .xltx |
Sheets, merged cells, number/date formats, cell styling |
| CSV |
.csv .tsv |
Auto-detected delimiter and encoding, header detection |
About PDF rendering
PDF pages are not rendered pixel-for-pixel. They are shown as extracted text
laid out at its real page position, plus the images embedded in the page.
This is a deliberate trade-off, not a missing feature. Pixel-accurate PDF rendering
needs font-program interpreters, JPEG 2000, CCITT/JBIG2 codecs and colour management -
historically some of the most vulnerability-prone code in any document stack. This
extension exists precisely to avoid shipping that surface. If you need an exact visual
copy of a page, use Open In System App from the toolbar.
Scanned PDFs with no text layer are detected and their page images are shown.
Features
- Extract embedded images - one click writes every image in the document to a
<name>-images/ folder next to it. Formats that cannot be displayed in a webview
(EMF, WMF, TIFF) are still extracted.
- Extract text - writes a
.txt next to the document and opens it.
- Find-in-document with match navigation, zoom, page-colour toggle, outline/bookmark sidebar.
- Sidebar tabs for bookmarks, embedded images and document metadata.
- Four UI languages: English, Turkish, German, French (
nlabsDoc.language).
- Remembers scroll position, zoom and active sheet per file.
Security posture
Documents are untrusted input. This extension treats them that way:
- No network. The webview's Content-Security-Policy has no
connect-src,
frame-src or remote script-src. It cannot make a request even if it wanted to.
- No
innerHTML. Every piece of document text reaches the DOM through
textContent, so document content can never be interpreted as markup or script.
- No telemetry. Nothing about your files leaves your machine.
- Zip-bomb guards. Office containers are rejected if total uncompressed size or
per-entry compression ratio exceeds a configurable limit.
- Path-traversal guards. Archive entry names with
.., absolute paths, drive
letters or NUL bytes are rejected outright.
- Size limits. Files above
nlabsDoc.maxFileSizeMb are refused before reading.
- Encrypted PDFs are not opened rather than decrypted with a guessed password.
- No image codecs of our own. JPEG passes through to the browser; raw samples
are re-encoded as PNG. JPEG 2000, CCITT and JBIG2 images are skipped, not decoded.
The extension is enabled in untrusted workspaces because it never executes anything
from the documents it reads.
Settings
| Setting |
Default |
Description |
nlabsDoc.language |
auto |
UI language (auto, tr, en, de, fr) |
nlabsDoc.theme |
paper |
Page tint: paper (white page), auto (dim surface in dark themes), editor (editor background). The toolbar has a toggle for the current tab. |
nlabsDoc.maxFileSizeMb |
100 |
Refuse documents larger than this |
nlabsDoc.zip.maxUncompressedMb |
512 |
Zip-bomb guard: total uncompressed size |
nlabsDoc.zip.maxCompressionRatio |
200 |
Zip-bomb guard: per-entry ratio |
nlabsDoc.sheet.maxRows |
5000 |
Rows rendered per sheet |
nlabsDoc.sheet.maxColumns |
200 |
Columns rendered per sheet |
nlabsDoc.csv.delimiter |
auto |
CSV field delimiter |
nlabsDoc.showImages |
true |
Render embedded images |
nlabsDoc.pdf.textLayout |
columns |
Keep page positions, or reflow into one column |
Commands
| Command |
Description |
nLabs: Open Document Preview |
Open the selected file in the viewer |
nLabs: Reload Document |
Re-read the file from disk |
nLabs: Extract Embedded Images |
Write all embedded images to a folder |
nLabs: Extract Text |
Write extracted text to a .txt file |
nLabs: Open In System App |
Hand the file to the OS default application |
Known limits
- PDF: no pixel-accurate page rendering (see above); encrypted PDFs are not opened;
JPEG 2000 / CCITT / JBIG2 images are skipped.
- Word: no headers/footers, footnotes, shapes or text boxes; revision marks are
shown as accepted.
- Excel: formulas are shown as their last cached value; charts and pivot tables are
not rendered; theme colours fall back to defaults.
- Legacy binary
.doc and .xls are not supported - they are not OOXML.
Development
pnpm install
pnpm run compile # TypeScript -> out/
pnpm run package # produces the .vsix
node scripts/smoke.mjs --dir "C:/some/folder" # run parsers over real files
node scripts/make-icon.mjs # regenerate images/icon.png
Press F5 to launch an Extension Development Host.
License
MIT (c) nLabs - Cuma Kose
| |