『壹』 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