PDF 阅读
约 317 字大约 1 分钟
2024-03-28
概述
主题支持在 markdown 中嵌入 PDF 文件,它能够在页面中直接阅读 PDF 。
该功能由 vuepress-plugin-md-power 提供支持。
配置
该功能默认不启用。你需要在主题配置中开启。
.vuepress/config.ts
export default defineUserConfig({
theme: plumeTheme({
markdown: {
pdf: true,
},
})
})语法
最简单的语法如下:
@[pdf](url)当需要打开特定页面时,使用 page 选项指定页码。为了兼容旧用法,也支持在 pdf 后直接跟随页码的简写形式 @[pdf 2](url)。
@[pdf page="2"](url)还可以添加更多的 选项到 @[pdf ] 中,更灵活的控制行为。
@[pdf page="2" width="100%" ratio="16:9"](url)page- 页码,默认为1width- 宽度,默认为100%height- 高度,默认为autoratio- 宽高比,默认为1:0.9,仅当未指定height时生效
示例
默认
输入:
@[pdf](https://plume.pengzhanbo.cn/files/sample-1.pdf)输出:
设置页码为 2
输入:
@[pdf page="2"](https://plume.pengzhanbo.cn/files/sample-1.pdf)输出:
指定高度
输入:
@[pdf height="400px"](https://plume.pengzhanbo.cn/files/sample-1.pdf)输出:
宽高比 21:29
输入:
@[pdf ratio="21:29"](https://plume.pengzhanbo.cn/files/sample-1.pdf)输出:
贡献者
更新日志
2026/9/16 18:24
查看所有更新日志
685a2-feat(plugin-md-power): enhance pdf embed syntax (#997)于1d04d-feat: add builtin auto-import-components (#932)于c4637-docs: update pdf assets于4d236-feat(theme)!: add collections support (#704)于0fd6c-refactor(theme): improve types and flat config (#524)于164e8-docs: improve docs于9a441-docs: update doc于
