File tree Expand file tree Collapse file tree 5 files changed +94
-8
lines changed
Expand file tree Collapse file tree 5 files changed +94
-8
lines changed Original file line number Diff line number Diff line change 11data /
2+ build /
3+ dist /
4+ .spec
25* .pdf
36* .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,17 +21,33 @@ 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+ )
3034
35+ if response .lower () != "y" :
36+ print ("Operation canceled." )
37+ return
3138
32- if __name__ == "__main__" :
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 } " )
43+
44+
45+ def main ():
3346 args = parser .parse_args ()
3447
3548 files = pdf_files_in_directory (Path (args .directory ))
3649 if files is not None :
3750 merge_pdf_files (files , args .output )
51+
52+
53+ main ()
Original file line number Diff line number Diff line change 1+ # -*- mode: python ; coding: utf-8 -*-
2+
3+
4+ a = Analysis (
5+ ['pdf_merger.py' ],
6+ pathex = [],
7+ binaries = [],
8+ datas = [],
9+ hiddenimports = [],
10+ hookspath = [],
11+ hooksconfig = {},
12+ runtime_hooks = [],
13+ excludes = [],
14+ noarchive = False ,
15+ optimize = 0 ,
16+ )
17+ pyz = PYZ (a .pure )
18+
19+ exe = EXE (
20+ pyz ,
21+ a .scripts ,
22+ [],
23+ exclude_binaries = True ,
24+ name = 'pdf_merger' ,
25+ debug = False ,
26+ bootloader_ignore_signals = False ,
27+ strip = False ,
28+ upx = True ,
29+ console = True ,
30+ disable_windowed_traceback = False ,
31+ argv_emulation = False ,
32+ target_arch = None ,
33+ codesign_identity = None ,
34+ entitlements_file = None ,
35+ )
36+ coll = COLLECT (
37+ exe ,
38+ a .binaries ,
39+ a .datas ,
40+ strip = False ,
41+ upx = True ,
42+ upx_exclude = [],
43+ name = 'pdf_merger' ,
44+ )
You can’t perform that action at this time.
0 commit comments