中国广告设计网站纯注册app拉新挣钱
中国广告设计网站,纯注册app拉新挣钱,国内电商平台排名,龙岩网站制作设计pdfkit#xff0c;把 HTMLCSS 格式的文件转换成 PDF 格式文档的一个工具。
其实#xff0c;pdfkit 是 html 转成 pdf 工具包 wkhtmltopdf 的 Python 封装。所以#xff0c;首先安装 wkhtmltopdf 。 一般情况下#xff0c;wkhtmltopdf需要手动安装#xff0c;网站是 https…pdfkit把 HTMLCSS 格式的文件转换成 PDF 格式文档的一个工具。
其实pdfkit 是 html 转成 pdf 工具包 wkhtmltopdf 的 Python 封装。所以首先安装 wkhtmltopdf 。 一般情况下wkhtmltopdf需要手动安装网站是 https://wkhtmltopdf.org/downloads.html根据自己的操作系统下载对应的版本即可。ps记住安装目录啊下面要用到。
上面说到了pdfkit这个模块这个是第三方模块需要安装使用pip安装即可。
pip install pdfkit
示例
pdfkit 可以将网页、html文件以及字符串生成pdf文件 import pdfkitconfg pdfkit.configuration(wkhtmltopdfC:\Python35\wkhtmltopdf.exe)# 这里指定一下wkhtmltopdf的路径这就是我为啥在前面让记住这个路径
url https://blog.csdn.net/fenglepeng/article/details/103670893
pdfkit.from_url(url, aaa.pdf, configurationconfg)
# from_url这个函数是从url里面获取内容
# 这有3个参数第一个是url第二个是文件名第三个就是khtmltopdf的路径pdfkit.from_file(my.html, bbb.pdf, configurationconfg)
# from_file这个函数是从文件里面获取内容
# 这有3个参数第一个是一个html文件第二个是文生成的pdf的名字第三个就是khtmltopdf的路径html
div
h1title/h1
pcontent/p
/divpdfkit.from_string(html, ccc.pdf, configurationconfg)
# from_file这个函数是从一个字符串里面获取内容
# 这有3个参数第一个是一个字符串第二个是文生成的pdf的名字第三个就是khtmltopdf的路径
API
def from_url(url, output_path, optionsNone, tocNone, coverNone, configurationNone, cover_firstFalse): 把从URL获取文件转换为PDF文件 :param url: URL 或 URL列表 :param output_path: 输出PDF文件的路径。如果是参数等于False意味着文件将会以字符串的形式返回得到文本文件。:param options: (可选) dict with wkhtmltopdf global and page options, with or w/o -- :param toc: (可选) dict with toc-specific wkhtmltopdf options, with or w/o -- :param cover: (可选) string with url/filename with a cover html page :param configuration: (可选)实例化 pdfkit.configuration.Configuration() :param configuration_first: (可选) if True, cover always precedes TOC Returns成功返回True def from_file(input, output_path, optionsNone, tocNone, coverNone, cssNone, configurationNone, cover_firstFalse): Convert HTML file or files to PDF document :param input: path to HTML file or list with paths or file-like object :param output_path: path to output PDF file. False means file will be returned as string. :param options: (optional) dict with wkhtmltopdf options, with or w/o --:param toc: (optional) dict with toc-specific wkhtmltopdf options, with or w/o -- :param cover: (optional) string with url/filename with a cover html page :param css: (optional) string with path to css file which will be added to a single input file :param configuration: (optional) instance of pdfkit.configuration.Configuration() :param configuration_first: (optional) if True, cover always precedes TOC Returns: True on success def from_string(input, output_path, optionsNone, tocNone, coverNone, cssNone, configurationNone, cover_firstFalse):Convert given string or strings to PDF document:param input: string with a desired text. Could be a raw text or a html file:param output_path: path to output PDF file. False means file will be returned as string.:param options: (optional) dict with wkhtmltopdf options, with or w/o --:param toc: (optional) dict with toc-specific wkhtmltopdf options, with or w/o --:param cover: (optional) string with url/filename with a cover html page:param css: (optional) string with path to css file which will be added to a input string:param configuration: (optional) instance of pdfkit.configuration.Configuration():param configuration_first: (optional) if True, cover always precedes TOCReturns: True on success
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/87663.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!