系列文章:
1. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF
1.https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html
2.https://skjhcreator.blogspot.com/2023/06/jpgpdfjpgpdf.html
3.只要點兩下,就能將放進input的一堆PDF轉成各自的WORD
3.https://skjhcreator.blogspot.com/2023/10/inputpdfword.html
4.只要點兩下,就能將放進input的一堆PDF轉成在ouput資料夾內的各自的WORD
4.https://skjhcreator.blogspot.com/2023/10/inputpdfouputword.html
5.只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF
1. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF
1.https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html
2.https://skjhcreator.blogspot.com/2023/06/jpgpdfjpgpdf.html
3.只要點兩下,就能將放進input的一堆PDF轉成各自的WORD
3.https://skjhcreator.blogspot.com/2023/10/inputpdfword.html
4.只要點兩下,就能將放進input的一堆PDF轉成在ouput資料夾內的各自的WORD
4.https://skjhcreator.blogspot.com/2023/10/inputpdfouputword.html
5.只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF
Recently, I heard in the administrative office that there is often a need to convert many Word documents into corresponding PDFs, and then merge those PDFs into a single PDF. This final PDF is required to be submitted to superiors. Especially when submitting course plans, it often gets so busy that one forgets which Word document corresponds to which PDF, and whether any PDFs are missing after merging. Hearing these concerns, I started to think about whether it is possible to skip these steps and directly convert multiple Word documents into a single PDF.
使用教學(Instructional videos):
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234使用教學(Instructional videos):
以下是開發過程與原始碼 (Development process and code):
安裝套件pypiwin32 、 PyPDF2
指令(command):
pip install pypiwin32
pip install PyPDF2
程式名稱(Program name):AllWord2OnePDF.py
程式內容(Code):
import glob
import os
from win32com import client
import time
from PyPDF2 import PdfFileMerger
# Word轉PDF
path=os.getcwd()
os.chdir(path+'\\input\\')
word = client.Dispatch("Word.Application")
for i in glob.glob('*.doc'):
doc = word.Documents.Open(path+'\\input\\'+i)
doc.SaveAs("{}.pdf".format(path+'\\output\\'+i[:-4]),17)
doc.Close()
for i in glob.glob('*.docx'):
docx = word.Documents.Open(path+'\\input\\'+i)
docx.SaveAs("{}.pdf".format(path+'\\output\\'+i[:-5]),17)
docx.Close()
word.Quit()
print("WORD轉PDF 完成!!")
# PDF合併
pdf_lst = list()
# 設定Input為目標路徑
os.chdir(path+'\\output')
target_path=str(os.path.abspath(os.getcwd()))
# 列出目標路徑內的pdf
for f in os.listdir(target_path):
if f.endswith('.pdf'):
pdf_lst.append(os.path.join(target_path,f))
# pdf 合併
file_merger = PdfFileMerger()
for pdf in pdf_lst:
file_merger.append(pdf)
output_name =path+"\\"+"merge"+str(time.strftime("%H-%M-%S",time.localtime()))+".pdf"
file_merger.write(output_name)
print("PDF合併 完成!!")
資料來源: