Skip to content

About

Convert Slidev presentations into editable PPTX and ODP files with real text frames instead of slide images

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

slidev-to-pptx

Turns a Slidev presentation into an editable PPTX or ODP: real text frames with paragraphs, images as objects, embedded fonts.

Slidev's own slidev export --format pptx writes every slide as a full-page image — the file opens in PowerPoint or Impress, but there is nothing to click. This tool reads the rendered DOM instead and builds native shapes from it.

slidev export --format pptx this tool
text runs 0 656
text frames 0 466
images as objects 0 97
embedded fonts 0 2

(measured on an 88-slide deck)

Install

npm install -D slidev-to-pptx
npx playwright install chromium

dom-to-pptx pulls in puppeteer, which downloads its own copy of Chrome. This tool never uses it — it drives the browser through playwright-chromium. Skip that download:

PUPPETEER_SKIP_DOWNLOAD=true npm install -D slidev-to-pptx

For ODP output you also need LibreOffice (soffice on your PATH).

Use

Run it from your Slidev project, the same place you run slidev itself:

npx slidev-to-pptx slides.md              # slides.pptx next to the deck
npx slidev-to-pptx slides.md --odp        # plus slides.odp
npx slidev-to-pptx *.md --out build/ --odp

Several decks run one after another on their own ports; one failure does not stop the rest, and the exit code is 1 if any deck failed.

Only the resulting paths go to stdout, progress goes to stderr, so the output pipes cleanly:

npx slidev-to-pptx *.md --odp --quiet | xargs open

Options

Option
--out <path> target file or directory
--odp also convert to ODP (needs LibreOffice)
--odp-only convert to ODP and delete the PPTX
--port <n> first port for the dev server (default 3099)
--frame-pad <pct> padding added to text frame width, default 3, 0 disables
--no-normalize-bg skip background image/colour preprocessing
--no-fix-bullets skip list indent correction
--quiet print only the resulting paths

How it works

  1. start your project's Slidev dev server
  2. find the print route — in Slidev 52 that is /export/, not /print
  3. wait the way Slidev's own exporter does
  4. calibrate the viewport until the slide scale is exactly 1
  5. prepare the DOM: crop background images, lift background colours, measure the intended list indent
  6. call dom-to-pptx in the page context
  7. post-process the PPTX: fix list indents, pad text frames
  8. optionally soffice --convert-to odp

Two traps worth knowing about

The print route. In Slidev 52.14 the .print-slide-container elements live under /export/?print=clicks. Under /print?print=clicks there are none. The tool tries both and uses whichever works.

The scale. The container's own transform is the identity matrix — the scale sits one level above it. Checking only the container misses it. It shows up when you compare getBoundingClientRect() (scaled) against offsetWidth (unscaled).

That is not cosmetic: getComputedStyle reports font-size unscaled while getBoundingClientRect reports geometry scaled. At any scale other than 1 the two disagree and every derived PPTX coordinate is off by exactly that factor. The tool therefore adjusts the viewport iteratively until the effective scale is 1.

Preprocessing

Steps 5 and 7 compensate for two upstream issues. Both can be switched off to see their effect.

Background images are stretched. dom-to-pptx passes background-size into the objectFit parameter of its image renderer. That function only knows the object-fit values contain, cover, none and scale-down; anything else falls through to fill and gets stretched to the box. The two CSS properties only share contain and cover, so background-size: auto 110% or 70% comes out distorted. This tool pre-renders the crop CSS would actually show — full computation of background-size, -position and -repeat — and inserts it as an <img> at box size, so fill becomes correct. See NOTICE.md.

Slide backgrounds are dropped. dom-to-pptx never emits a <p:bg>; it renders the root element's children but not its background colour. Dark slides would come out white. The colour is copied onto the container first.

List indents are too wide. marL is set far larger than the original (measured 0.673 in against 0.307 in), which pushes the text right and costs line width — causing wraps that are not in the original. The correct value is measured in the DOM and the indents are scaled to match, so nested levels keep their ratio.

Text frames have no slack. Frame width is set to exactly the text width measured in the browser. Text that already wraps therefore has zero reserve: the longest line is by definition exactly as wide as the box. LibreOffice differs by fractions of a percent and wraps a line early, in the worst case mid-word. Measured across one deck, every element under 2 % reserve wrapped wrongly and everything from 7 % up was fine, so frames are padded by 3 %. Position is compensated for centred and right-aligned text.

Checking the result

npx slidev-pptx-eval slides.md          # measure against a PNG reference
npx slidev-pptx-compare .out/slides     # PDF with reference and result side by side

slidev-pptx-eval renders the deck to PNG with Slidev, builds both the image-based export and this tool's output, converts them back through soffice → pdftoppm, and compares pixel by pixel. It also reads the OOXML to count text runs, shapes and images, because pixel counts say nothing about whether a file is editable.

Measured against the PNG reference, share of visibly differing pixels:

deck image-based export this tool
88 slides 3.48 % 4.43 %
9 slides 1.31 % 2.02 %

The image-based export is a pixel copy, so it is the practical ceiling for visual fidelity — at zero editability.

A caveat on that metric: once a block of text is shifted vertically by more than its stroke width it counts as fully different, so the number saturates. It tracks area-level problems well (missing backgrounds, distorted images) and is blunt for typography. Use the side-by-side PDF for that.

Needs soffice, pdftoppm (poppler) and magick (ImageMagick).

Not verified

  • Mermaid diagrams — the decks tested contained none
  • Code blocks — only two seen so far; Shiki emits one span per token
  • Video — whether a playable video, a still or nothing ends up in the PPTX

Typography aside, LibreOffice sets slightly more line spacing than Chromium, and that accumulates vertically.

Requirements

Node 20.6+, a Slidev project, playwright-chromium with its Chromium installed. LibreOffice for --odp. For slidev-pptx-eval additionally poppler and ImageMagick.

License

MIT, see LICENSE. Third-party components in NOTICE.md.

About

Convert Slidev presentations into editable PPTX and ODP files with real text frames instead of slide images

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages