Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit414fc48

Browse files
committed
Add solution to ch13 section 3 exercise 2
1 parent97bf116 commit414fc48

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎ch13-interact-with-pdf-files/3-concatenating-and-merging-pdfs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@
2727
output_path=Path.home()/"concatenated.pdf"
2828
withoutput_path.open(mode="wb")asoutput_file:
2929
pdf_merger.write(output_file)
30+
31+
32+
# ***********
33+
# Exercise 2
34+
#
35+
# Using the same `PdfFileMerger` instance from exercise 1, merge the
36+
# file `merge3.pdf` in-between the pages from `merge1.pdf` and
37+
# `merge2.pdf` using `.merge()`.
38+
#
39+
# The final result should be a PDF with three pages. The first page
40+
# should have the number `1` on it, the second should have `2`, and the
41+
# third should have `3`.
42+
# ***********
43+
44+
pdf_merger=PdfFileMerger()
45+
pdf_merger.append(str(output_path))
46+
47+
pdf_path=BASE_PATH/"merge3.pdf"
48+
pdf_merger.merge(1,str(pdf_path))
49+
50+
output_path=Path.home()/"merged.pdf"
51+
withoutput_path.open(mode="wb")asoutput_file:
52+
pdf_merger.write(output_file)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp