PDF Resize

approved

by puhhh

Resize embedded PDF files with wiki-link dimensions. - This plugin has not been manually reviewed by Obsidian staff.

33 downloadsUpdated 6d agoMIT

PDF Resize

License: MIT Version Obsidian TypeScript Tests

Resize embedded PDFs in Obsidian with the same wiki-link width syntax used for images.

See CHANGELOG.md for release history.

Features

  • Uses familiar syntax: ![[file.pdf|500]]
  • Works in Reading view and Live Preview
  • Accepts whole-number widths from 1 to 4096 pixels and enforces a minimum rendered width of 100px
  • Keeps embeds responsive without exceeding the available note width
  • Leaves PDFs without a valid width at Obsidian's default size
  • Makes no network requests and does not modify vault files

Installation

  1. Download main.js, manifest.json, and styles.css.
  2. Create .obsidian/plugins/pdf-resize/ inside your vault.
  3. Copy all three files into that folder.
  4. Reload Obsidian.
  5. Open Settings → Community plugins and enable PDF Resize.

Usage

Add a pixel width after the PDF filename:

![[documents/example.pdf|500]]

The rendered PDF is 500px wide in Reading view and Live Preview. In a narrower pane, it shrinks to fit the available space. Source mode shows the Markdown text, so no resize is applied there.

Widths must be whole numbers from 1 through 4096. Values from 1 through 99 are clamped to the minimum rendered width of 100px; values from 100 through 4096 are used as written. 0, values above 4096, and malformed values are ignored:

![[example.pdf|0]]
![[example.pdf|4097]]
![[example.pdf|wide]]

For example, ![[example.pdf|10]] renders at 100px, while ![[example.pdf|500]] renders at 500px.

![[example.pdf]] keeps Obsidian's default PDF size.

Development

Use Node.js 24 for parity with the reference plugin toolchain.

npm ci
npm run dev
npm run lint
npm test
npm run build
  • npm ci installs the locked dependency set used by CI and release builds.
  • npm install is appropriate when intentionally updating dependencies.
  • npm run dev builds in watch mode.
  • npm run lint checks source and tests.
  • npm test runs the Vitest suite.
  • npm run build creates production main.js.

Do not edit main.js by hand.

Release

GitHub Releases are published by GitHub Actions when a version tag is pushed.

  1. Update package.json, package-lock.json, manifest.json, versions.json, and CHANGELOG.md.
  2. Run npm run lint, npm test, npm run build, and npm audit --omit=dev --audit-level=high.
  3. Commit the release changes, open a pull request into main, and merge it.
  4. Create and push a signed version tag from main:
git tag -s -m "X.Y.Z" X.Y.Z HEAD
git push origin main
git push origin X.Y.Z

The release workflow verifies that the tag version matches package.json, manifest.json, and versions.json, audits production dependencies, runs lint and tests, rebuilds main.js, creates GitHub artifact attestations, and uploads manifest.json, main.js, and styles.css. Obsidian requires the GitHub release tag to match manifest.json exactly, so use 1.0.0, not v1.0.0.

Manual verification

  • Check ![[file.pdf|500]] in Reading view and Live Preview.
  • Switch between both views and edit the width in Live Preview.
  • Check two PDF embeds with different widths in the same note.
  • Check PDF paths with spaces and subfolders.
  • Scroll a long note until an off-screen PDF becomes visible.
  • Check 1, 10, and 99; confirm each renders at 100px with the toolbar and first PDF page visible.
  • Check 100, 399, 500, and 4096; confirm each uses the requested width.
  • Confirm 0, 4097, decimals, negative numbers, text, and mixed values are ignored.
  • Confirm ![[file.pdf]] and non-PDF embeds stay unchanged.
  • Resize the pane below and above requested width.
  • Reload Obsidian and confirm sizing still works without console errors.

Privacy and safety

PDF Resize works locally. It does not make network requests, collect data, write notes, or change PDF files.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.