Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85e7cc1

Browse files
authored
Add files via upload
1 parent c9d42b4 commit 85e7cc1

File tree

9 files changed

+23
-0
lines changed

9 files changed

+23
-0
lines changed

python-image-to-pdf/gentleman.pdf

6.44 KB
Binary file not shown.

python-image-to-pdf/gentleman.png

4.98 KB
Loading

python-image-to-pdf/image-to-pdf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import img2pdf
2+
3+
#opening from filename
4+
with open("gentleman.pdf","wb") as f:
5+
f.write(img2pdf.convert('gentleman.png'))
6+
7+
with open("sample.pdf","wb") as f:
8+
f.write(img2pdf.convert('sample.jpg'))
9+
10+
#multiple inputs (variant 1)
11+
with open("output1.pdf","wb") as f:
12+
f.write(img2pdf.convert("gentleman.png", "sample.jpg"))
13+
14+
#multiple inputs (variant 2)
15+
with open("output2.pdf","wb") as f:
16+
f.write(img2pdf.convert(["gentleman.png", "sample.jpg"]))
17+
18+
#specify paper size (A4)
19+
a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))
20+
layout_fun = img2pdf.get_layout_fun(a4inpt)
21+
with open("paper_size.pdf","wb") as f:
22+
f.write(img2pdf.convert('sample.jpg', layout_fun=layout_fun))

python-image-to-pdf/output1.pdf

56.9 KB
Binary file not shown.

python-image-to-pdf/output2.pdf

56.9 KB
Binary file not shown.

python-image-to-pdf/paper_size.pdf

50.8 KB
Binary file not shown.

python-image-to-pdf/readme.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You can go through the tutorial https://www.roytuts.com/convert-image-to-pdf-using-python/

python-image-to-pdf/sample.jpg

49.9 KB
Loading

python-image-to-pdf/sample.pdf

50.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)