600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > python读pdf文件字体大小_如何使用python中的pyPDF2更改pdf文件中的字体

python读pdf文件字体大小_如何使用python中的pyPDF2更改pdf文件中的字体

时间:2024-07-11 19:47:52

相关推荐

python读pdf文件字体大小_如何使用python中的pyPDF2更改pdf文件中的字体

如何更改pyPDF 2模块中的字体。在

我试过print(help(canvas.Canvas))

我尝试了initialFontName = None和{}

但我的文字没有改变。另外,我使用raspberry pi和raspbian操作系统来完成这个任务。在

这是我的密码can = canvas.Canvas(packet, pagesize=letter, initialFontName = 'Helvetica', initialFontSize = 5)

now = datetime.datetime.now()

can.drawString(250, 500, self.get_Firstn1 + ' ' + self.get_Middlen1 +' ' + self.get_Lastn1)

can.drawString(300, 550, "Hello World")

can.drawString(350, 600,"Hello")

can.save()

packet.seek(0)

new_pdf = PdfFileReader(packet)

existing_pdf = PdfFileReader(open("Sample.pdf", "rb"))

existing_pdf.decrypt('')

output = PdfFileWriter()

# add the "watermark" (which is the new pdf) on the existing page

page = existing_pdf.getPage(0)

page.mergePage(new_pdf.getPage(0))

output.addPage(page)

#write "output" to a real file

outputStream = open("destination.pdf", "wb")

output.write(outputStream)

outputStream.close()

#open pdf file

opener ="open" if sys.platform == "darwin"else "xdg-open"

subprocess.call([opener, "destination.pdf"])

我试图改变字体,如Arial,Times New Roman,Cambria等,但它只接受Helvetica,文本大小和字体没有改变。在

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。