# -*- coding: UTF-8 -*-
import sys
from reportlab.lib.pagesizes import portrait
from reportlab.pdfgen import canvas
from PIL import Image
 
 
 
def imgtopdf(input_paths, outputpath):
    (maxw, maxh) = Image.open(input_paths).size
    c = canvas.Canvas(outputpath, pagesize=portrait((maxw, maxh)))
    c.drawImage(input_paths, 0, 0, maxw, maxh)
    c.showPage()
    c.save()
 
# 调用demo:
imgtopdf("c:\xx.png", "xx.pdf")

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注