PDF 报告
为本命盘、合盘、太阳回归等生成专业的 PDF 报告。PDF 报告模块允许您创建包含解读、星盘和数据表格的可定制占星报告。
概述
PDF 报告功能提供:
- 多种报告类型:本命盘、合盘、复合盘、行运、太阳回归、月亮回归、推运、数字学和中国星座
- 可定制模板:创建和管理自定义布局的 PDF 模板
- 自动计算:占星数据实时计算并合并到您的模板中
- 专业输出:高质量 PDF 生成,支持页眉、页脚、页码和自定义 CSS
支持的报告类型
| 报告类型 | 描述 |
|---|---|
natal | 包含行星位置、宫位和相位的出生星盘分析 |
synastry | 两张星盘之间的关系相容性分析 |
composite | 关系的合并星盘 |
transit | 当前行星行运与本命盘的对照 |
solar-return | 年度生日星盘 |
lunar-return | 月度月亮回归星盘 |
progressions | 二次推运 |
numerology | 数字学计算与分析 |
chinese | 中国星座报告 |
生成 PDF 报告
通过提供出生数据,并可选择指定模板来生成 PDF 报告。
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/generate" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"reportType": "natal",
"subject": {
"name": "John Doe",
"birthDate": {
"year": 1990,
"month": 6,
"day": 15,
"hour": 14,
"minute": 30
},
"birthPlace": {
"name": "London, UK",
"latitude": 51.5074,
"longitude": -0.1278,
"timezone": "Europe/London"
}
}
}' \
--output natal-report.pdf请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
reportType | string | 是 | 报告类型(见上方支持的类型) |
templateId | string | 否 | 要使用的特定模板 ID(如未提供则使用默认模板) |
subject | object | 是 | 主要当事人的出生数据 |
partner | object | 否 | 伴侣的出生数据(合盘/复合盘必填) |
transitDate | object | 否 | 行运/回归报告的目标日期 |
Subject 对象
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
name | string | 是 | 当事人姓名 |
birthDate | object | 是 | 出生日期和时间 |
birthDate.year | number | 是 | 出生年份 |
birthDate.month | number | 是 | 出生月份(1-12) |
birthDate.day | number | 是 | 出生日期(1-31) |
birthDate.hour | number | 是 | 出生小时(0-23) |
birthDate.minute | number | 是 | 出生分钟(0-59) |
birthPlace | object | 是 | 出生地点 |
birthPlace.name | string | 是 | 地点名称 |
birthPlace.latitude | number | 是 | 纬度(-90 到 90) |
birthPlace.longitude | number | 是 | 经度(-180 到 180) |
birthPlace.timezone | string | 是 | IANA 时区标识符 |
响应
端点返回包含生成报告的 PDF 文件(application/pdf)。
合盘报告示例
生成比较两张出生星盘的合盘报告:
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/generate" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"reportType": "synastry",
"subject": {
"name": "Person A",
"birthDate": {
"year": 1990,
"month": 6,
"day": 15,
"hour": 14,
"minute": 30
},
"birthPlace": {
"name": "London, UK",
"latitude": 51.5074,
"longitude": -0.1278,
"timezone": "Europe/London"
}
},
"partner": {
"name": "Person B",
"birthDate": {
"year": 1988,
"month": 3,
"day": 22,
"hour": 9,
"minute": 15
},
"birthPlace": {
"name": "Paris, France",
"latitude": 48.8566,
"longitude": 2.3522,
"timezone": "Europe/Paris"
}
}
}' \
--output synastry-report.pdf太阳回归报告示例
生成特定年份的太阳回归报告:
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/generate" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"reportType": "solar-return",
"subject": {
"name": "John Doe",
"birthDate": {
"year": 1990,
"month": 6,
"day": 15,
"hour": 14,
"minute": 30
},
"birthPlace": {
"name": "London, UK",
"latitude": 51.5074,
"longitude": -0.1278,
"timezone": "Europe/London"
}
},
"transitDate": {
"year": 2025,
"month": 6,
"day": 15,
"hour": 0,
"minute": 0
}
}' \
--output solar-return-2025.pdf模板管理
模板定义 PDF 报告的布局和内容。每个模板与特定的报告类型关联。
列出模板
bash
curl -X GET "https://api.astroapi.cloud/api/pdf-reports/templates" \
-H "X-Api-Key: your-api-key"返回组织专属模板和全局(共享)模板。
获取特定模板
bash
curl -X GET "https://api.astroapi.cloud/api/pdf-reports/templates/{templateId}" \
-H "X-Api-Key: your-api-key"创建模板
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/templates" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "templates",
"attributes": {
"name": "My Natal Report Template",
"description": "Custom natal chart report",
"reportType": "natal",
"editorConfig": {},
"pageSettings": {
"format": "A4",
"orientation": "portrait",
"margins": {
"top": 20,
"right": 20,
"bottom": 20,
"left": 20
}
},
"isDefault": true
}
}
}'模板属性
| 属性 | 类型 | 描述 |
|---|---|---|
name | string | 模板名称(1-100 个字符) |
description | string | 可选描述 |
reportType | string | 此模板适用的报告类型 |
editorConfig | object | Editor.js 块配置 |
pageSettings | object | 页面布局设置 |
customCss | string | 自定义 CSS 样式 |
isDefault | boolean | 设为此报告类型的默认模板 |
isActive | boolean | 模板是否激活 |
页面设置
| 设置 | 类型 | 描述 |
|---|---|---|
format | string | 页面大小:"A4" 或 "Letter" |
orientation | string | "portrait"(纵向)或 "landscape"(横向) |
margins | object | 页边距(mm),包含 top、right、bottom、left |
header | object | 页眉配置 |
footer | object | 页脚配置 |
pageNumbers | object | 页码设置 |
页眉/页脚配置
json
{
"header": {
"enabled": true,
"height": 15,
"content": "My Astrology Report"
},
"footer": {
"enabled": true,
"height": 15,
"content": "Generated by AstroAPI"
},
"pageNumbers": {
"enabled": true,
"position": "bottom-center",
"format": "Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span>"
}
}更新模板
bash
curl -X PATCH "https://api.astroapi.cloud/api/pdf-reports/templates/{templateId}" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "templates",
"attributes": {
"name": "Updated Template Name"
}
}
}'删除模板
bash
curl -X DELETE "https://api.astroapi.cloud/api/pdf-reports/templates/{templateId}" \
-H "X-Api-Key: your-api-key"复制模板
将现有模板(包括全局模板)复制到您的组织:
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/templates/{templateId}/duplicate" \
-H "X-Api-Key: your-api-key"设置默认模板
将模板设为其报告类型的默认模板:
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/templates/{templateId}/set-default" \
-H "X-Api-Key: your-api-key"预览模板
使用示例数据预览模板的渲染效果(返回 HTML):
bash
curl -X POST "https://api.astroapi.cloud/api/pdf-reports/preview" \
-H "X-Api-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"templateId": "your-template-id"
}'模板解析顺序
生成 PDF 时,系统按以下顺序解析使用哪个模板:
- 指定模板:如果请求中提供了
templateId - 组织默认模板:该组织针对此报告类型的默认模板
- 全局默认模板:该报告类型的全局(共享)默认模板
所需权限
| 端点 | 权限 |
|---|---|
| 列出/获取模板 | content:read |
| 生成 PDF | content:read |
| 预览模板 | content:read |
| 创建模板 | content:create |
| 更新模板 | content:update |
| 删除模板 | content:delete |
| 复制模板 | content:create |
| 设置默认 | content:update |
报告内容
生成的报告包含:
- 当事人信息:姓名、出生日期、时间和地点
- 行星位置:所有主要行星的星座、宫位和度数
- 宫位起点:所有 12 个宫位的起点和星座
- 相位:带容许度和解读的行星相位
- 解读文本:CMS 来源的每个位置和相位的文本内容
实际内容取决于模板配置和可用的 CMS 内容。