GithubHelp home page GithubHelp logo

alphawong / html2pdf Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 2.0 179 KB

A simple docker image for easily convert html to PDF based on [wkhtmltopdf] for invoice issuing

License: Mozilla Public License 2.0

Dockerfile 0.34% Go 7.40% Shell 0.27% HTML 91.74% Makefile 0.11% AMPL 0.14%
pdf api docker

html2pdf's Introduction

pipeline status coverage report

Objective

Offer an API to convert html to pdf via POST method

How

It wraps wkhtmltopdf for the html convert to pdf. The reason we do not use weasyprint is that weasyprint do not offer a suitable converted result. However, wkhtmltopdf always return a suitable result. Also, chrome headless mode do not have the feature that we needed such as footer and header.

Run via docker

docker run -it --rm -p 8000:80 registry.gitlab.com/alphawong/html2pdf

Run

./reload.sh

Screenshot

wkhtmltopdf

alt wkhtmltopdf

weasyprint

alt wkhtmltopdf

Postman collection

https://www.getpostman.com/collections/0e61ae04d5f54cb17a5a

Postman

alt

cURL

curl -X POST \
  http://127.0.0.1:8000/convert \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: 455468a3-a8cb-4e88-a9bb-b3e9b61b505d' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F file=@/home/alpha/works/src/github.com/AlphaWong/html2pdf/simple/http2.html \
  -F '--footer-left="[page] lalamove"'

Pre-condition

  1. wkhtmltopdf for converting binary
  2. Noto-unhinted.zip for i18n issue

Issue

  1. Noto-unhinted can resolve the cjk and thai character display issue.

Reference

  1. https://qiita.com/nju33/items/b80d92a4257edeb4b9a1
  2. https://developers.google.com/web/updates/2017/04/headless-chrome#create_a_pdf_dom

Credit

  1. [email protected]
  2. [email protected]
  3. [email protected]
  4. [email protected]
  5. [email protected]
  6. [email protected]

html2pdf's People

Contributors

alphawong avatar wcsiu avatar

Stargazers

 avatar Jimmy Lung avatar Andrew Mok avatar Hyper avatar Leslie H. avatar Jack Tang avatar Simon Tse Chi Ming avatar  avatar  avatar

Watchers

James Cloos avatar Simon Tse Chi Ming avatar  avatar  avatar  avatar

Forkers

minixxie wcsiu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.