简体   繁体   English

使用 fpdf 将 jpg 添加到 pdf

[英]Adding jpg to a pdf, using fpdf

I am creating a jpg in my python program, and would like to make it part of a pdf with fpdf.我正在我的 python 程序中创建一个 jpg,并希望将它作为带有 fpdf 的 pdf 的一部分。 Is that possible without writing it to a file first?如果不先将其写入文件,这可能吗?

I don't think so.我不这么认为。 In the fpdf image docs, it says for the name param in adding an image with fpdf.image(name, x = None, y = None, w = 0, h = 0, type = '', link = '') :fpdf 图像文档中,它说在添加带有fpdf.image(name, x = None, y = None, w = 0, h = 0, type = '', link = '')的图像时的name参数:

name: 
 
     Path or URL of the image.

This implies that you're not passing an object representing an image directly in as the parameter, but only the path to an image that is already saved to disk as a file.这意味着您没有直接将表示图像的对象作为参数传递,而只是传递已作为文件保存到磁盘的图像的路径。 This is so when you call something like pdf.output('tuto1.pdf', 'F') , it will build the PDF at that point from the text, images, etc.这就是当您调用pdf.output('tuto1.pdf', 'F') ,它将在该点从文本、图像等构建 PDF。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM