Skip to content

A simple Go/Fiber api that handles generating PDF documents form HTML input or URL endpoints.

Notifications You must be signed in to change notification settings

rolandihms/go-webkit-pdf-engine

Repository files navigation

Go API for generating PDF files using the Webkit Headless Engine

A simple Go/Fiber api that handles generating PDF documents form HTML input or URL endpoints.

Run Using Air

`air --build.exclude_dir "public"`

... Documentation to be generated

URL to PDF

 curl -X POST -H "Content-Type: application/json" --data "{\"title\":\"Test\",\"url\":\"https://nampost.com.na\"}" localhost:3000/url-to-pdf/

`{
    "status": "success",
    "message": "PDF CReated Successfully",
    "error": "",
    "filename": "test_101031-04-04.pdf"
}`

HTML to PDF

 curl -X POST -H "Content-Type: application/json" --data "{\"title\":\"Test\",\"html\":\"<div>Html is here</div>\"}" localhost:3000/html-to-pdf/

`{
    "status": "success",
    "message": "PDF CReated Successfully",
    "error": "",
    "filename": "test_101045-04-04.pdf"
}`

... TO DO:

  1. Allow more specific format options, page sizes, dpi, aspect ratios
  2. Docker image and multi stage build
  3. Compare speed of webkit vs headless chromium.
  4. Document the path and including the Webkit binary
  5. Implement Templ templating, compare vs mustache and plain HTML
  6. Allow option to respond with raw file data instead of the URL
  7. Clean HTML input and sanitize
  8. Clean public/ folder or delete temp files after generating from html

Issues

Webkit running older version of CSS. No border radius and other limitations

Rename to aod_pdf_api

Port to echo

Interface iplementation

Pass context into The GeneratePDFDocument ->

Context todo...

Dependency injection...

Understand.

SOLID principles

Loosely Coupled

About

A simple Go/Fiber api that handles generating PDF documents form HTML input or URL endpoints.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published