File tree Expand file tree Collapse file tree 4 files changed +44
-7
lines changed
Expand file tree Collapse file tree 4 files changed +44
-7
lines changed Original file line number Diff line number Diff line change 11data /
22build /
33dist /
4+ .spec
45* .pdf
56* .pyc
Original file line number Diff line number Diff line change @@ -7,19 +7,19 @@ This is a basic project to merge pdf files.
77To get help, run:
88
99``` sh
10- path/to/exe -h
10+ python -m pdf_merger -h
1111```
1212
1313You can use it like this:
1414
1515``` sh
16- path/to/exe -d dir/with/pdf/files -o result/file.pdf
16+ python -m pdf_merger -d dir/with/pdf/files -o result/file.pdf
1717```
1818
1919Or using the long form:
2020
2121``` sh
22- path/to/exe --directory dir/with/pdf/files --output result/file.pdf
22+ python -m pdf_merger --dir dir/with/pdf/files --output result/file.pdf
2323```
2424
2525> [ !NOTE]
Original file line number Diff line number Diff line change 1+ ## ** 1.1.0** &emsp ; <sub ><sup >2024-07-20 (e37d7b607f61e70b27caf17aeb0918eea4db0ee5...5121c8390c5637cded459375869982d4bbfdee9d)</sup ></sub >
2+
3+ ### Features
4+
5+ - first version (e49d7ce4751fbaecef63cda4388eeb392ea01e40)
6+ - better error handling and user interaction when merge (c6191f25fbc199ad97dca496c1bbf178dfd24c20)
7+
8+ ### Bug Fixes
9+
10+ - corrects the long form of the directory argument in example and command in examples (5121c8390c5637cded459375869982d4bbfdee9d)
11+
12+ ### Merges
13+
14+ - branch 'release/1\. 0\. 0' (a4dea194f2faeea0d78fccad0f68601401a51f82)
15+ - tag '1\. 0\. 0' into develop (f0f5b8f992140cc68a556d6294e1ff2fb476c9dd)
16+
17+ ### ? ? ?
18+
19+ - Initial commit (e37d7b607f61e70b27caf17aeb0918eea4db0ee5)
20+
21+ <br >
22+
23+
Original file line number Diff line number Diff line change @@ -21,12 +21,25 @@ def pdf_files_in_directory(path: Path) -> Optional[list[Path]]:
2121
2222
2323def merge_pdf_files (files : list [Path ], result_path : Path ):
24- writer = PdfWriter ()
24+ try :
25+ writer = PdfWriter ()
2526
26- for file in files :
27- writer .merge (None , fileobj = PdfReader (file , True ))
27+ for file in files :
28+ writer .merge (None , fileobj = PdfReader (file , True ))
2829
29- writer .write (result_path .with_suffix (PDF_SUFFIX ))
30+ if result_path .with_suffix (PDF_SUFFIX ).exists ():
31+ response = input (
32+ f"The file { result_path .name } .pdf exists, do you want to overwrite? (y/N): "
33+ )
34+
35+ if response .lower () != "y" :
36+ print ("Operation canceled." )
37+ return
38+
39+ writer .write (result_path .with_suffix (PDF_SUFFIX ))
40+ print ('PDFs merged succesfully!' )
41+ except Exception as e :
42+ print (f"Failed to merge: { e } " )
3043
3144
3245def main ():
You can’t perform that action at this time.
0 commit comments