Ramanpreet Singh
Ramanpreet Singh

Reputation: 37

Image from url to PDF

How can I convert images saved on cloudinary to pdf using their url with python3 + django? I tried using pdfkit but it's not fetching the image from url and creates a blank pdf.

Upvotes: 1

Views: 1361

Answers (2)

Ramanpreet Singh
Ramanpreet Singh

Reputation: 37

Thank you all for the helpful answers. I used urllib.request.urlretrieve(url, filename) to download the images from the urls to local system and then with the help of PyFPDF converted them to the pdf file.

Link: https://pyfpdf.readthedocs.io/en/latest/Tutorial/index.html

Upvotes: 0

Yakir Perlin
Yakir Perlin

Reputation: 184

You can just set the format to pdf, like this:

https://res.cloudinary.com/demo/f_pdf/bike.jpg

Python:

CloudinaryImage("bike.jpg").image(fetch_format="pdf")

Upvotes: 2

Related Questions