Skip to content

Commit 323ab1e

Browse files
committed
Added word to PDF converter
1 parent 50972f9 commit 323ab1e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Word to PDF converter/wordToPDF.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
from docx2pdf import convert
3+
4+
def convert_word_to_pdf(word_file_path):
5+
try:
6+
output_pdf_path = os.path.splitext(word_file_path)[0] + ".pdf"
7+
convert(word_file_path, output_pdf_path)
8+
print("Conversion successful. PDF saved")
9+
except Exception as e:
10+
print(f"Error occurred during conversion: {e}")
11+
12+
if __name__ == "__main__":
13+
# Replace the paths below with the actual paths of your Word files
14+
word_files = [
15+
r"enter word file location path 1",
16+
r"enter word file location path 2",
17+
r"enter word file location path 3",
18+
r"enter word file location path 4",
19+
r"enter word file location path 5",
20+
r"enter word file location path 6",
21+
r"enter word file location path 7",
22+
r"enter word file location path 8",
23+
r"enter word file location path 9",
24+
# you can add as many as you want
25+
]
26+
27+
for word_file_path in word_files:
28+
convert_word_to_pdf(word_file_path)

0 commit comments

Comments
 (0)