1

I am relatively new to the Python-PDF relationship. If I had a list of .PNG files/pictures, how would I go about creating a PDF document with these files/pictures? And is it possible to have, for example, 4 per page? I would not need any other formatting... the requirement is very basic.

Thanks

2 Answers 2

3

There may be a python-reportlab solution, but based on your requirement, you probably don't need it. You can simply use ImageMagick to accomplish the same.

First merge multiple PNGs into one PNG destined to be one page

montage -mode concatenate a*.png group_a.png
montage -mode concatenate b1.png b2.png b3.png b4.png group_b.png
...

Then simply

convert group_*.png one.pdf

The resulting PDF would have 2 pages, each of which contains multiple PNGs.

Sign up to request clarification or add additional context in comments.

Comments

0

The python program img2pdf will store images into PDFs (it might not work on some PNGs, though), and there are several n-up examples in Python for putting multiple images on a page. My own library pdfrw has a 4-up example script with it. (The generic term for n-up for printing purposes is "page imposition", so that is sometimes a good search term.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.