“Python Convertir imágenes a PDF” Código de respuesta

PIL IMG TO 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 Convertir imágenes a 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

PIL IMG TO 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

Respuestas similares a “Python Convertir imágenes a PDF”

Preguntas similares a “Python Convertir imágenes a PDF”

Más respuestas relacionadas con “Python Convertir imágenes a PDF” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código