56 lines
1.8 KiB
Markdown
56 lines
1.8 KiB
Markdown
# 生成 API 文档 PDF 指南
|
||
|
||
本文档说明如何将 API 文档转换为 PDF 格式。
|
||
|
||
## 前提条件
|
||
|
||
1. 安装 DocFX
|
||
|
||
```bash
|
||
dotnet tool install -g docfx
|
||
```
|
||
|
||
2. 安装 wkhtmltopdf
|
||
从官方网站下载并安装:<https://wkhtmltopdf.org/downloads.html>
|
||
|
||
## 生成步骤
|
||
|
||
1. 首先生成 API 元数据:
|
||
|
||
```bash
|
||
docfx metadata docfx.json
|
||
```
|
||
|
||
2. 然后生成 HTML 文档:
|
||
|
||
```bash
|
||
docfx build docfx.json
|
||
```
|
||
|
||
这会在 `_site` 目录下生成 HTML 文档。
|
||
|
||
3. 最后使用 wkhtmltopdf 将 HTML 文件转换为 PDF:
|
||
|
||
```bash
|
||
wkhtmltopdf --enable-local-file-access --page-size A4 --margin-top 20 --margin-bottom 20 --margin-left 20 --margin-right 20 --footer-left "大气传输计算库 API 文档" --footer-right "[page]/[topage]" --footer-spacing 8 --footer-font-size 8 --no-header-line _site/docs/introduction.html _site/docs/usage_examples.html _site/api/AirTransmission.AtmosphericTransmittanceCalculator.html _site/api/AirTransmission.WeatherCondition.html _site/api/AirTransmission.WeatherType.html AirTransmission-API-Doc.pdf
|
||
```
|
||
|
||
## 命令参数说明
|
||
|
||
- `--enable-local-file-access`: 允许访问本地文件
|
||
- `--page-size A4`: 设置页面大小为 A4
|
||
- `--margin-top/bottom/left/right 20`: 设置页边距为 20mm
|
||
- `--footer-left`: 设置页脚左侧文本
|
||
- `--footer-right`: 设置页脚右侧文本(页码)
|
||
- `--footer-spacing`: 设置页脚间距
|
||
- `--footer-font-size`: 设置页脚字体大小
|
||
- `--no-header-line`: 不显示页眉分隔线
|
||
|
||
## 注意事项
|
||
|
||
1. 必须按顺序执行上述三个步骤
|
||
2. 确保所有的 HTML 文件都已经正确生成
|
||
3. 如果遇到路径问题,请使用完整的文件路径
|
||
4. 如果文档包含中文,确保系统安装了相应的中文字体
|
||
5. 生成的 PDF 文件默认保存在当前目录下
|