MultiSite/pdf2.py
2025-09-12 17:03:28 +08:00

105 lines
3.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.cidfonts import UnicodeCIDFont
# Register a Chinese-capable font
pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))
# File path
file_path = "E:/ministry_of_helpers_requirements.pdf"
# Create PDF
c = canvas.Canvas(file_path, pagesize=letter)
width, height = letter
# Title
c.setFont("STSong-Light", 18)
c.drawString(50, height - 50, "Ministry of Helpers 网站需求分析报告")
c.setFont("STSong-Light", 14)
y = height - 80
c.drawString(50, y, "一、前端功能分析")
y -= 24
c.setFont("STSong-Light", 12)
frontend_lines = [
"1. 首页 / 品牌介绍:平台口号及核心价值展示",
"2. 角色入口切换:雇主 / 家佣 双向导航",
"3. 查找 & 发布:雇主浏览候选人,家佣申请职位",
"4. 订阅计划 & 服务包Lite/Standard/Premium 套餐展示",
"5. 常见问题FAQs费用、合同流程等解答",
"6. 客户评价 & 合作伙伴:好评轮播与合作机构展示",
"7. 社区 & 内容运营:论坛、博客入口",
"8. 移动端推广App 下载按钮App Store / Google Play",
"9. 多渠道联系Sign up/Log in/Contact us/Policy 链接",
]
for line in frontend_lines:
if y < 60:
c.showPage()
y = height - 50
c.setFont("STSong-Light", 12)
c.drawString(60, y, line)
y -= 18
# Backend section
if y < 100:
c.showPage()
y = height - 50
c.setFont("STSong-Light", 14)
c.drawString(50, y, "二、后端开发需求分析")
y -= 24
c.setFont("STSong-Light", 12)
backend_lines = [
"模块 | 职能描述 | 技术要点",
"1. 用户与权限 | 注册登录、角色控制 | JWT/Session, OAuth, RBAC",
"2. 数据存储 | 档案、简历、订阅记录 | PostgreSQL/MySQL, MongoDB",
"3. 搜索与筛选 | 多维度检索、分页、收藏 | ElasticSearch, Redis 缓存",
"4. 订阅与支付 | 计划管理、计费续费 | Stripe/PayPal API, 定时任务",
"5. 表单与流程 | 预约、申请、多步状态机 | 后端验证, 流程引擎, 邮件/SMS",
"6. CMS管理 | 博客、FAQ、评价后台维护 | Strapi/自研 Admin, 富文本",
"7. 社区论坛 | 帖子评论、点赞、审核 | Discourse 或自建, WebSocket",
"8. 移动 App 支持 | API接口, 文件上传 | REST/GraphQL, S3 签名 URL",
"9. 安全与合规 | 防注入、速率限制、WAF | OWASP, Nginx+WAF, HTTPS",
"10. 性能与监控 | 缓存、日志、监控 | Redis, Prometheus/Grafana, ELK",
"11. 第三方集成 | 地图、邮件/SMS、政府 API | Google Maps, Twilio, 错误重试",
]
for line in backend_lines:
if y < 60:
c.showPage()
y = height - 50
c.setFont("STSong-Light", 12)
c.drawString(50, y, line)
y -= 18
# Tech stack section
if y < 100:
c.showPage()
y = height - 50
c.setFont("STSong-Light", 14)
c.drawString(50, y, "三、推荐技术栈示例")
y -= 24
c.setFont("STSong-Light", 12)
tech_lines = [
"- 后端框架Node.js (Express/Koa) 或 Python (FastAPI/Django)",
"- 数据库PostgreSQL + Redis 缓存 + S3 对象存储",
"- 认证OAuth2 + JWTRBAC",
"- 异步消息RabbitMQ / Kafka",
"- 搜索Elasticsearch",
"- CMSStrapi 或 Keystone",
"- 部署Docker + Kubernetes / AWS ECSCI/CD",
]
for line in tech_lines:
if y < 60:
c.showPage()
y = height - 50
c.setFont("STSong-Light", 12)
c.drawString(60, y, line)
y -= 18
c.save()
file_path