最近在自学python 有个png转PDF的需求,然后网站找了下。
def png2pdf(name):
imgdoc = fitz.open(name)
pdfbytes = imgdoc.convertToPDF() # 使用图片创建单页的 PDF
imgpdf = fitz.open("pdf", pdfbytes)
imgpdf.save(name[:-4] + '.pdf')
运行提示 'Document' object has no attribute 'convertToPDF'
然后查了下源码
我自己理解的意思是convertToPDF是老版本的方法,新版本下应该用 convert_to_pdf
运行下,解决
- 39 convertToPDF attribute Document Python39 converttopdf attribute document 39 quot attributeerror attribute 39 attributeerror attribute nonetype 39 attributeerror tensorflow attribute 39 attribute nonetype children 39 attributeerror antialias attribute 39 attribute pending socket 39 attributeerror attribute copy_src 39 attributeerror attribute深度 39 attribute module numpy