๐ Word Module Guide
This page is currently only available in Chinese. Please switch to ็ฎไฝไธญๆ for the full content.
๐ Word Module Guide
Core Scenariosโ
Word to PDFโ
import office
# Single file
office.word.docx2pdf(
path='./contract.docx',
output_path='./pdf_files/'
)
# Batch convert a whole folder
office.word.docx2pdf(
path='./all_documents/',
output_path='./pdf_files/'
)
Merge Multiple Word Documentsโ
office.word.merge4docx(
input_path='./weekly_reports/',
output_path='./summary/',
new_word_name='team_weekly_report'
)
Convert Between Doc and Docxโ
# Doc to Docx
office.word.doc2docx(
input_path='./legacy_report.doc',
output_path='./modern/'
)
# Docx to Doc
office.word.docx2doc(
input_path='./modern_report.docx',
output_path='./legacy/'
)
Extract Images from Wordโ
office.word.docx4imgs(
word_path='./product_manual.docx',
img_path='./extracted_images/'
)
Full APIโ
Real-World Example: Batch Convert Weekly Reports to PDFโ
import office
import os
src_dir = './weekly_reports_2026_05/'
dst_dir = './weekly_reports_pdf/'
os.makedirs(dst_dir, exist_ok=True)
office.word.docx2pdf(
path=src_dir,
output_path=dst_dir
)
FAQโ
Q: Word to PDF fails? A: Most of the time it's because LibreOffice/Office is missing.
- Windows: install Office or WPS
- macOS:
brew install --cask libreoffice - Linux:
sudo apt install libreoffice
Q: Fonts change after conversion? A: The fonts used in the document are missing from the system. Embed fonts in the document before conversion.
AI ๅๅ
ฌๆ็่ฏพ
35 ่ฎฒ AI ่ชๅจๅๅๅ
ฌๅฎๆ่ฏพ็จ Python + AI ๅค็ ExcelใWordใPDFใ้ฎไปถ็ญๅๅ
ฌๅบๆฏใ
ๅปๅญฆไน