2023年10月17日 星期二

只要點兩下,就能將放進input的一堆PDF轉成各自的WORD

系列文章:
01.python 不管何時何地,只要點兩下,資料夾內的所有pdf都會合併成一個pdf
https://skjhcreator.blogspot.com/2022/06/pythonpdfpdf.html
02.python 只要點兩下,分別對各資料夾內的pdf合併,合併後的檔名要讓人知道來自哪個資料夾 
https://skjhcreator.blogspot.com/2022/06/python-pdf.html
03. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF
03.https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html
04.只要點兩下,就能將一堆的JPG轉成一個PDF,並以JPG所在的資料夾名稱為PDF的檔名
04.https://skjhcreator.blogspot.com/2023/06/jpgpdfjpgpdf.html
05.只要點兩下,就能將放進input的一堆PDF轉成各自的WORD
05.https://skjhcreator.blogspot.com/2023/10/inputpdfword.html
06.只要點兩下,就能將放進input的一堆PDF轉成在ouput資料夾內的各自的WORD 
06.https://skjhcreator.blogspot.com/2023/10/inputpdfouputword.html
07.只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF
07.https://skjhcreator.blogspot.com/2024/09/word-word-pdf.html
08.只要點兩下,就可以將資料夾input內的所有Word通通轉成一個PDF
08.https://skjhcreator.blogspot.com/2025/07/inputwordpdf.html
09.只要點兩下兩次,就能依照設定拆分指定PDF頁數並合併成設定好的一個PDF
09.https://skjhcreator.blogspot.com/2025/09/pdfpdf.html
10.只要點兩下,就能將input資料夾內所有PDF進行容量壓縮
10.https://skjhcreator.blogspot.com/2026/04/inputpdf.html

With just a double-click, you can convert a bunch of PDF files placed in the "input" folder into their respective Word documents.

        最近遇到了問題,希望能將一堆PDF轉成各自的WORD,然後再進行編輯。目前市面上有類似的網站,可以提供PDF轉WORD。偏偏有些機密的PDF就不適合放到那些網站進行轉檔,怕洩密。若要不洩密,仍要轉檔成WORD,則需要購買版權。剛好,Python 就有PDF轉成DOCX的套件。但是需要填入檔名,一個一個地轉。因此,希望能夠有一種程式,只要將一堆的PDF放進INPUT資料夾,接著點兩下,相對應的WORD就會出現。

 Recently, I encountered a problem and I hope to be able to convert a bunch of PDF files into individual Word documents for editing. Currently, there are similar websites available in the market that offer PDF to Word conversion. However, some confidential PDF files are not suitable for uploading to those websites for conversion due to security concerns. If I want to convert them to Word without compromising security, I would need to purchase a license. Luckily, there is a Python package available for converting PDF to DOCX. However, it requires filling in the file name and converting them one by one. Therefore, I would like to have a program where I can simply place a bunch of PDF files in the input folder, double-click, and the corresponding Word documents will be generated.

 

下載檔案解壓密碼:demo1234

Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):
 

 
以下是開發過程與原始碼 (Development process and code):
 
安裝pdf2docx套件(Install the pdf2docx suite)
指令(command):pip install pdf2docx
 
程式名稱(Program name):PdfToWord.py
程式內容(Code):

#請安裝套件 pdf2docx
#指令 pip install pdf2docx
from pdf2docx import Converter
import os

#取得當前目錄
Path = os.getcwd()
#取得input路徑
InputPath = Path+'\\input\\'
#取得input資料夾下的目錄或檔案
dirs = os.listdir(InputPath)

if dirs != []:
    for dir in dirs:
        fileName,fileExt = dir.split('.')
        if fileExt.lower() == 'pdf':
            PdfCvWord = Converter(InputPath+dir)
            PdfCvWord.convert(Path+'\\'+fileName+'.docx')
            PdfCvWord.close()
else:
    print('Input is empty!!')

 
 
資料來源:


沒有留言:

張貼留言

只要點兩下,就能依據文字檔內容,創建對應的資料夾

         最近針對書本的目錄,需要創建相對應的資料夾。過去要找到該書的目錄網頁,一行一行地複製網頁文字,再一行一行地創建資料夾、重新命名、貼上。或是直接依據該書的紙本目錄,一行一行地看,創建資料夾、重新命名、一行一行地打字。         Recently, I oft...