pdf 生成器
将 Diplodoc 项目变成PDF 软件包 .
安装
npm i -g @diplodoc/pdf-generator
使用量
步骤1:生成单页文件
运行 @diplodoc/cli 命令。 这将为每个目录(TOC)文件创建一个输出文件夹,并有一个单页文件.
npx -- @diplodoc/cli@latest -i ./docs -o ./docs-output --pdf
步骤2: 将单页文件转换为 PDF
运行 @diplodoc/pdf-generator 命令。 这将在单个页面文件旁边创建 PDF 文件 .
npx -- @diplodoc/pdf-generator@latest -i ./docs-output
该工具还以HTML格式文件的形式为用户提供了对信头和页脚的灵活定制,其路径可以通过相应的选项 -- -- Custom-header和 -- Custom-footer.
默认情况下,页眉没有设置,但右下角的页码设置在页脚上,如下文示例所示.
npx -- @diplodoc/pdf-generator@latest -i ./docs-output
下面还有一个带有自定义标题的命令的例子(示例- 客户头. html)和自定义页脚(实例- footer.html) (中文(简体) ).
即使您指定了自定义页脚,编号仍然保留在右下角.
npx -- @diplodoc/pdf-generator@latest -i ./docs-output --custom-header ./example-custom-header.html --custom-footer ./example-custom-footer.html
通过参数
| 选项 | 类型 | 必要的 | 默认值 | 说明 |
|---|---|---|---|---|
custom-header | string (filepath) (英语) | 没有 | "" "" (英语) | HTML 文件路径, 包含生成的 PDF 页面的自定义标题内容 . |
custom-footer | string (filepath) (英语) | 没有 | <div style="position: relative;width: 100%;height: 0;"><div style="position: absolute;right: 20px;bottom: 0;font-size: 10px;z-index: 0;padding: 0 5px;background: white;"><span class="pageNumber"></span></div></div> | HTML 文件路径, 包含生成的 PDF 页面的自定义页脚内容 . |
屏幕截图上有自定义页眉和页脚的生成的 pdf 页面示例 测试编号 :图像相片( s) /海关负责人-测试-ts-整合-工作-页面*
发展
先决条件
- 节点 18.x
- 图形映射
- 幽灵标记
没有图形磁体和幽灵记录吗?
跟随 这个 用于安装所需依赖的指南.
运行测试
npm run test