# pdfservice-mix **Repository Path**: usench/pdfservice-mix ## Basic Information - **Project Name**: pdfservice-mix - **Description**: html转pdf和image - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-04-10 - **Last Updated**: 2025-04-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README HTML-PDF服务(pdf和图片jpg合并版) ============ 使用方法: 1. 上传HTML内容 2. 给出URL地址 注意:HTML/CSS 使用的长度单位,现在还不是太准确(如1cm),生成出来的PDF的元素长度 会较为短,暂时比较好的方案是用相对的尺寸。请看 calibrate.html 上传HTML内容 ------------ 发送HTTP POST请求到 `http://pdf.starpost.cn` ,Body 内容为 HTML 文件内容, Content-Type为text/html。 发送内容必须为 UTF-8 编码,返回内容就是PDF内容 | HTTP Header | 意思 | 默认值 | |---------------|------------------|------------| | Page-Width | 页面宽度(毫米) | 100 | | Page-Height | 页面宽度(毫米) | 100 | | Margin-Top | 上边框(毫米) | 0 | | Margin-Bottom | 下边框(毫米) | 0 | | Margin-Left | 左边框(毫米) | 0 | | Margin-Right | 右边框(毫米) | 0 | 给出URL地址 ----------- 发送HTTP GET请求到 `http://pdf.starpost.cn?url=` ,系统会从给出的下载 HTML内容。 以上HTTP头部同样适用。 测试 ===== curl -o output.pdf http://pdf.starpost.cn -s --data @myfile.html curl -o output.pdf http://pdf.starpost.cn?url=http://www.qq.com ====== 【新】 post请求json: toType: 1=pdf 2=image 在 wkhtmltopdf 中,如果未明确指定单位,默认的单位是 ​毫米 (mm)。 在 wkhtmltoimage 中,如果没有明确指定单位,默认的单位是 ​像素 (px)。 pdf: ```json { "html": "这是一个HTML5的网页

Hello HTML5

", "args": { "page-width": "100", "page-height": "100", "margin-top": "1", "page-size": "A4", "no-debug-javascript": "", "minimum-font-size": "20" }, "toType": 1 } ``` image: ```json { "html": "这是一个HTML5的网页

Hello HTML5

", "args": { "width": "100", // 必须为字符串,否则报错 "crop-w": "200", "crop-h": "200", "no-debug-javascript": "" }, "toType": 2 } ```