- Published on
Python : Convert PDF to Docx with pdf2docx
- Authors
- Name
- Bryan Wibowo
- X
- @brynwibowo
Install pdf2docx
pip install pdf2docx
Code
- Buat file python, misal dengan nama file
convertpdf2docx.py
convertpdf2docx.py
from pdf2docx import Converter
pdf_file = 'samplefile.pdf'
docx_file = 'samplefile.docx'
cv = Converter(pdf_file)
cv.convert(docx_file)
cv.close()
- Tentukan file PDF yang akan dikonversi, misalkan file
samplefile.pdf
nama file harus sama dengan value pada variabel pdf_file
pada code di atas
Eksekusi Code
python3 convertpdf2docx.py
lihat file hasil Konversi