导出
Slides
PDF
导出为 PDF 或 PNG 的功能基于 Playwright 实现渲染。因此,使用此功能前需要安装
playwright-chromium
。 如果你需要在 CI 环境下进行导出,那么阅读 playwright CI 指南 会对你有所启发。
安装 playwright-chromium
:
$ npm i -D playwright-chromium
接着,使用如下命令即可将你的幻灯片导出为 PDF:
$ slidev export
稍作等待,即可在 ./slides-export.pdf
路径下看到你幻灯片的 PDF 文件。
如果你想要导出使用暗色主题的幻灯片,请使用 --dark
选项:
$ slidev export --dark
导出点击步骤
自 v0.21 起可用
默认情况下,Slidev 会将每张幻灯片导出为 1 页,并忽略点击动画。如果你想将多个步骤的幻灯片,分解为多个页面,请使用 --with-clicks
选项。
$ slidev export --with-clicks
PNGs and Markdown
当为命令传入 --format png
选项时,Slidev 会将每张幻灯片导出为 PNG 图片格式。
$ slidev export --format png
导出一系列幻灯片
默认情况下会导出演示文稿中的全部幻灯片。如果要导出特定的幻灯片或幻灯片范围,可以设置 --range
选项指定要导出的幻灯片。
You can also compile a markdown file composed of compiled png using --format md
.
$ slidev export --format md
Dark mode
In case you want to export your slides using the dark version of the theme, use the --dark
option:
$ slidev export --dark
Export Clicks Steps
Available since v0.21
By default, Slidev exports one page per slide with clicks animations disabled. If you want export slides with multiple steps into multiple pages, pass the --with-clicks
option.
$ slidev export --with-clicks
Slide range
You can also specify a range of slides to export with the --range
option.
$ slidev export --range 1,4-5,6
PDF outline
Available since v0.36.10
You can generate the PDF outline by passing the --with-toc
option.
$ slidev export --with-toc
Output filename
You can specify the output filename with the --output
option.
$ slidev export --output my-pdf-export
Or in the frontmatter configuration:
---
exportFilename: my-pdf-export
---
Export a range of slides
By default, all slides in the presentation are exported. If you want to export a specific slide or a range of slides you can set the --range
option and specify which slides you would like to export.
$ slidev export --range 1,6-8,10
该选项接受特定的幻灯片编号和范围。
上面的示例将导出幻灯片第 1、6、7、8、10 页。
Multiple entries
You can also export multiple slides at once.
$ slidev export slides1.md slides1.md
Or
$ slidev export *.md
In this case, each input file will generate its own PDf file.
演讲者注释
自 v0.36.8 起可用
只将演示者注释(每张幻灯片的最后一个注释块)导出到 PDF 格式的文本文档中。
$ slidev export-notes
This command also accept multiple entries like for the export command
单页应用(SPA)
请参阅 静态部署 章节。
支持导出功能的镜像
为了支持 Slidev 的导出功能,这里还提供了另一个更大的镜像,带有 playwright 标签。在你的工作目录下运行下面的命令:
docker run --name slidev -d --rm -it \
-v ${PWD}:/slidev \
-p 3030:3030 \
-e NPM_MIRROR="https://registry.npmmirror.com" \
tangramor/slidev:playwright
然后你可以你的工作目录下像这样使用 Slidev 的导出功能:
docker exec -i slidev npx slidev export --timeout 2m --output slides.pdf