zoukankan      html  css  js  c++  java
  • pdfkit安装使用

    centos 安装pdfkit
    1、先安装pdfkit依赖包 wkhtmltopdf
    安装方式:
    # wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm
    # yum localinstall wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm # 安装后会自动加入到环境变量中
    2、安装pdfkit
    # pip install pdfkit
    3、安装wkhtmltopdf(如报错 /usr/local/bin/wkhtmltopdf: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory)
    yum install libpng12

    windows可以下载win版本的wkhtmltopdf, 下载地址:http://wkhtmltopdf.org/downloads.html


    ########################## windows code ##############################
    import pdfkit

    config = pdfkit.configuration(wkhtmltopdf='C:wkhtmltopdfwkhtmltopdf.exe')
    options = {
    'page-size': 'Letter',
    'margin-top': '0.1in',
    'margin-right': '0.1in',
    'margin-bottom': '0.1in',
    'margin-left': '0.1in',
    'encoding': "UTF-8",
    }
    html = "<html><body>hello</body></html>"
    pdfkit.from_string(html,"html.pdf",configuration=config, options=options)

    # url = "http://www.baidu.com"
    # pdfkit.from_string(url,"html.pdf",configuration=config, options=options)

    ########################## linux code ##############################
    import pdfkit

    html = "<html><body>hello</body></html>"
    pdfkit.from_string(html, "html.pdf")

    ########################################################

  • 相关阅读:
    UML描述
    Tomcat优化
    Tomcat源码
    Tomcat架构
    搭建K8s集群[无需科学shangwang]
    minikube安装
    K8S核心组件和架构图
    Docker数据持久化
    Java 内存溢出(java.lang.OutOfMemoryError)的常见情况和处理方式
    cookie与session区别?
  • 原文地址:https://www.cnblogs.com/weiok/p/4938731.html
Copyright © 2011-2022 走看看