Sign inSign up

websvcin/pdf-service

By websvcin

•Updated 6 months ago

Generate PDFs from HTML templates via REST API using .NET 8 + Playwright. Docker-ready service.

Image
Developer tools
0

210

websvcin/pdf-service repository overview

⁠PDF Render Service (.NET 8 + Playwright)

⁠Documentation

šŸ‘‰ Open PDF Service Docs⁠

REST API to generate PDF files from HTML templates using Handlebars and Playwright (Chromium).

Designed for:

  • invoice generation
  • reports
  • certificates
  • dynamic documents
  • server-side HTML to PDF conversion

⁠Features

  • HTML → PDF rendering
  • Handlebars template engine
  • JSON data binding
  • A4 / Letter support
  • portrait / landscape mode
  • Docker ready
  • Swagger API documentation
  • .NET 8 support
  • headless Chromium (Playwright)

⁠Quick Start (Docker)

Pull image:

docker pull websvcin/pdf-service:latest

Run container:

docker run -p 8080:80 websvcin/pdf-service

Open Swagger UI:

http://localhost:8080/docs⁠


⁠API Endpoint

POST /api/render/pdf

Generates PDF from HTML template.


⁠Request Format

{ "template": { "type": "base64", "content": "PGgxPkhlbGxvIHt7bmFtZX19PC9oMT4=" }, "data": { "name": "John" }, "options": { "pageSize": "A4", "orientation": "portrait" } }


⁠Response

{ "contentType": "application/pdf", "pdfBase64": "JVBERi0xLjQKJ..." }

Convert base64 to PDF file.


⁠Example HTML Template

⁠Hello {{name}}

    {{#each items}}
  • {{this}}
  • {{/each}}

⁠Example CURL

curl -X POST http://localhost:8080/api/render/pdf⁠ -H "Content-Type: application/json" -d '{ "template":{ "type":"base64", "content":"PGgxPkhlbGxvIHt7bmFtZX19PC9oMT4=" }, "data":{ "name":"John" } }'


⁠Architecture

HTML Template ↓ Handlebars compile ↓ Playwright Chromium render ↓ PDF output (base64)


⁠Docker Build (local)

docker build -t pdf-service .

docker run -p 8080:80 pdf-service


⁠Dependencies

  • Microsoft.Playwright
  • Handlebars.Net
  • ASP.NET Core 8
  • Swashbuckle Swagger

⁠Swagger UI

/docs


⁠Roadmap

  • header & footer templates
  • css asset support
  • template storage
  • async rendering queue
  • watermark support

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:ab9845626…

Size

430.1 MB

Last updated

6 months ago

docker pull websvcin/pdf-service