標籤

bat (54) 作品 (41) python (24) shell (17) windows (11) 虛擬機 (11) php (10) CPP (6) KMS (6) 程式設計 (6) docker (5) 使用教學 (5) xoops (4) 公文 (4) Apache2 (3) Excel (3) juniper (3) 資料庫 (3) 轉檔 (3) mysql (2) 免動手 (2) 資料結構 (2) 軟體廣播 (2) 電腦維修 (2) Android Studio (1) Apple IPAD管理 (1) Arduino (1) CSS (1) LAMP (1) NAS (1) Ubuntu (1) VHD (1) Windows Server (1) 原因 (1) 程式應用 (1) 程式積木 (1) 編輯器 (1) 雲端硬碟 (1)

2023年10月17日 星期二

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

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!!')

 
 
資料來源:


沒有留言:

張貼留言

只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF

  系列文章: 1. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF 1. https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html 2. 只要點兩下,就能將一堆的JPG轉成一個PDF,並以JPG所在的資料夾名稱為...