Skip to content

weiQLog/html_to_pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

使用说明书

1.概述

该服务提供了两个接口,允许用户将 HTML 文本或 HTML 文件转换为 PDF 文件。服务监听在指定的端口上(默认为 10030)。

pull

docker pull 1505774577/html_to_pdf:1.0.0.dev

run

docker run -d -p 10030:10030 --cap-add=SYS_ADMIN 1505774577/html_to_pdf:1.0.0.dev

2.接口描述

2.1 /html-to-pdf (将 HTML 文本转换为 PDF)

  • 方法: POST
  • Content-Type: text/plain
  • 请求体: HTML 字符串
  • 响应: PDF 文件
  • 错误处理: 如转换失败,返回状态码 500 和错误信息

请求示例:

curl -X POST http://localhost:10030/html-to-pdf \
     -H "Content-Type: text/plain" \
     -d "<html><body><h1>您好</h1></body></html>" \
     --output document.pdf

2.2 /htmlfile-to-pdf (将 HTML 文件转换为 PDF)

  • 方法: POST
  • Content-Type: text/plain
  • 请求体: HTML 字符串
  • 响应: PDF 文件
  • 错误处理: 如转换失败,返回状态码 500 和错误信息 请求示例:
curl -X POST http://localhost:10030/htmlfile-to-pdf \
     -F "file=@path_to_html_file.html" \
     --output document.pdf

注意事项

  • 确保服务正常运行并能够访问指定的端口。
  • 当发送 HTML 文件时,确保文件内容是有效的 HTML。
  • 如果转换失败,请检查 HTML 内容是否符合标准。

About

html to pdf

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages