Code Monkey home page Code Monkey logo

html_to_pdf's Introduction

HTML转PDF的python工具

介绍

这个工具是模拟karbon后台的pdf生成过程,生成的pdf和最终后台生成的效果是一样的。

可以作为前端,测试pdf模版的工具。


环境

  • python3.9
  • pip20.2.3

安装

解决平台依赖(macOS)

因为pdf渲染库weasyprint需要GTK+lib, 所以需要安装一些平台依赖

下面的命令适用于 macOS,其他系统可参考 weasyprint依赖安装

brew install cairo pango gdk-pixbuf libffi libmagic

安装virtualenv

python3 -m pip install --user virtualenv

创建python运行环境

在当前目录运行 python3 -m venv env

安装依赖

pip install -r requirements.txt


用法

python html_to_pdf.py <HTML_name> <output_pdf_name>

例如

python html_to_pdf.py index.html output.pdf

html_to_pdf's People

Contributors

shawn-xinhai avatar

Watchers

 avatar

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.