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")

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

  • 相关阅读:
    Shiro加密
    SpringBoot操作MongoDB实现增删改查
    ArrayList 源码分析(JDK1.8)
    Java 内存泄漏
    Java 原型模式(克隆模式)
    3.2-3.3 Hive中常见的数据压缩
    7、html的body内标签之图片及表格
    6、html的body内标签之超链接
    5、html的body内标签之多行文本及下拉框
    3.1 HiveServer2.Beeline JDBC使用
  • 原文地址:https://www.cnblogs.com/weiok/p/4938731.html
Copyright © 2011-2022 走看看