Created
June 4, 2024 16:25
-
-
Save godie/fb708f26500bf43b5e1a8d26e396689c to your computer and use it in GitHub Desktop.
como unir pdfs con python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyPDF2 | |
# Crear un objeto PDF en blanco | |
pdf_merger = PyPDF2.PdfFileMerger() | |
# Obtener la lista de archivos PDF a unir | |
pdf_files = ['archivo1.pdf', 'archivo2.pdf', 'archivo3.pdf'] | |
# Iterar sobre los archivos PDF y agregarlos al objeto de combinación | |
for pdf_file in pdf_files: | |
with open(pdf_file, 'rb') as file: | |
pdf_reader = PyPDF2.PdfReader(file) | |
pdf_merger.append(pdf_reader) | |
# Escribir el archivo PDF combinado | |
output_file = 'archivo_combinado.pdf' | |
with open(output_file, 'wb') as file: | |
pdf_merger.write(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
si marca error tenes que instalar el PyPDF2
pip install PyPDF2