‘壹’ python 有没有将 html 文件转换为 pdf 的库
python 有没有将 html 文件转换为 pdf 的库
说明:将以下脚本拷贝到vi中,保存,修改权限执行,得到你想要的结果。
#!/bin/bash
cd /etc/named
cp honey.com.zone /tmp/honey.com.zone.bk
awk '/^@ IN NS nsl.honey.com./ {print "@ IN NS nsl.ashaur.com";next} \
/^www IN A 192.168.1.7/ {print "www IN A 192.168.1.6";next} \
{print}' honey.com.zone >/tmp/honey.com.zone.tmp
cp /tmp/honey.com.zone.tmp /etc/named/honey.com.zone
‘贰’ python下面有什么生成pdf文件的库
可以使用 pdfkit
功能:
1.wkhtmltopdf主要用于HTML生成PDF。
2.pdfkit是基于wkhtmltopdf的python封装,支持URL,本地文件,文本内容到PDF的转换,其最终还是调用wkhtmltopdf命令。是目前接触到的python生成pdf效果较好的。
‘叁’ python 怎么将数据整合生成pdf
pdf.py文件如下:
#!/usr/bin/python
from reportlab.pdfgen import canvas
def hello():
c = canvas.Canvas("helloworld.pdf")
c.drawString(100,100,"Hello,World")
c.showPage()
c.save()
hello()
diskreport.py文件如下:
#!/usr/bin/env python
import subprocess
import datetime
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def disk_report():
p = subprocess.Popen("df -h", shell=True, stdout=subprocess.PIPE)
# print p.stdout.readlines()
return p.stdout.readlines()
def create_pdf(input, output="disk_report.pdf"):
now = datetime.datetime.today()
date = now.strftime("%h %d %Y %H:%M:%S")
c = canvas.Canvas(output)
textobject = c.beginText()
textobject.setTextOrigin(inch, 11*inch)
textobject.textLines('''Disk Capcity Report: %s''' %date)
for line in input:
textobject.textLine(line.strip())
c.drawText(textobject)
c.showPage()
c.save()
report = disk_report()
create_pdf(report)
‘肆’ python生成pdf报告有什么好的思路
你要先生成一个模板,然后用 python 对模板进行修改。
如果是 pdf 模板:
可以使用 pyPdf 和 reportlab 包。参考
http://stackoverflow.com/questions/1180115/add-text-to-existing-pdf-using-python
如果是 word (.docx 文件)模板(建议使用 word 模板):
docx 文件可以用 zipfile 模块解压缩,然后进行修改替换,接着将 word 转 pdf。参考
http://stackoverflow.com/questions/16867594/find-and-replace-text-in-docx-file-python
http://stackoverflow.com/questions/6011115/doc-to-pdf-using-python
‘伍’ 请问怎么通过python爬虫获取网页中的pdf文件
首先把链接URL爬取出来,然后get流下载pdf文件,再用pdf模块来读取它。
‘陆’ python 把网站返回的数据流保存为一个文件(这个数据流是pdf)
http://outofmemory.cn/code-snippet/83/sanzhong-Python-xiazai-url-save-file-code