0% found this document useful (0 votes)
10 views1 page

Slike To PDF

Pictures to PDF

Uploaded by

jankoviid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Slike To PDF

Pictures to PDF

Uploaded by

jankoviid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Darko python script take pictures from folder and insert in pdf

You can use the `Python` `Pillow` and `PyPDF2` libraries to accomplish this. Here is a high-level overview of the
steps:

1. Install the required libraries: `pip install Pillow PyPDF2`


2. Import the necessary libraries:

python Copy code

from PIL import Image


import os
from PyPDF2 import PdfFileWriter, PdfFileReader

1. Load the images from the folder:

lua Copy code

folder_path = "path/to/folder"
images = [Image.open(os.path.join(folder_path, f)) for f in os.listdir(folder_path) if f.endswith(

1. Create a new PDF file or add the images to an existing one:

python Copy code

pdf_file = "result.pdf"
pdf_writer = PdfFileWriter()

for image in images:


pdf_writer.addPage(image.convert("RGB"))

with open(pdf_file, "wb") as fh:


pdf_writer.write(fh)

existing_pdf = "existing.pdf"
pdf_reader = PdfFileReader(existing_pdf)

for image in images:


pdf_reader.addPage(image.convert("RGB"))

with open(pdf_file, "wb") as fh:


pdf_reader.write(fh)

This should give you a basic idea of how to insert images into a PDF file using Python.
Regenerate
response

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy