“Gambar Python ke PDF” Kode Jawaban

Gambar ke PDF Python

#pip install img2pdf
import img2pdf
with open("name.pdf","wb") as f:
	f.write(img2pdf.convert(['a.png','b.png']))
    
Frail Frog

Buat pdf dari gambar python

from PIL import Image

im1 = Image.open("/Users/apple/Desktop/bbd.jpg")
im2 = Image.open("/Users/apple/Desktop/bbd1.jpg")
im3 = Image.open("/Users/apple/Desktop/bbd2.jpg")
im_list = [im2,im3]

pdf1_filename = "/Users/apple/Desktop/bbd1.pdf"

im1.save(pdf1_filename, "PDF" ,resolution=100.0, save_all=True, append_images=im_list)
Thoughtful Toad

Gambar ke PDF Python

#pip install img2pdf
import img2pdf
with open("name.pdf","wb") as f:
	f.write(img2pdf.convert(['a.png','b.png']))
Frail Frog

python simpan gambar ke pdf

from PIL import Image

image1 = Image.open(r'path where the image is stored\file name.png')
im1 = image1.convert('RGB')
im1.save(r'path where the pdf will be stored\new file name.pdf')
Delightful Dolphin

Python mengonversi gambar ke pdf

import img2pdf
import os
from datetime import datetime 

# convert all files ending in .jpg inside a directory
dirname = "C:/Projects/Python/ImageConverter/Image/"
imgs = []
for fname in os.listdir(dirname):
	if not fname.endswith(""):
		continue
	path = os.path.join(dirname, fname)
	if os.path.isdir(path):
		continue
	imgs.append(path)

# Save file as PDF to specific folder
root = 'C:\ConvertedImages'
today = datetime.today().strftime('%Y-%m-%d_%H-%M')
name = (today + '_Multiple.pdf')
filePath = os.path.join(root, name)


with open(filePath,"wb") as f:
	f.write(img2pdf.convert(imgs))
Seahawk

Gambar Python ke PDF

import os
import img2pdf
#Method 1
with open("Output.pdf", "wb") as file:
    file.write(img2pdf.convert([i for i in os.listdir('Path of image_Directory') if i.endswith(".jpg")]))
#Method 2
from fpdf import FPDF
Pdf = FPDF()
list_of_images = ["1.jpg", "2.jpg"]
for i in list_of_images: # list of images with filename
    Pdf.add_page()
    Pdf.image(i,x,y,w,h)
Pdf.output("yourfile.pdf", "F")
sincap

Jawaban yang mirip dengan “Gambar Python ke PDF”

Pertanyaan yang mirip dengan “Gambar Python ke PDF”

Lebih banyak jawaban terkait untuk “Gambar Python ke PDF” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya