๐ PDF API Reference
This page is currently only available in Chinese. Please switch to ็ฎไฝไธญๆ for the full content.
๐ PDF API Reference
Sub-package:
popdf| Install:pip install popdfImport:import officeorimport popdf
The PDF module is the most feature-rich module in python-office (13 functions).
Function Overviewโ
| Function | Description |
|---|---|
pdf2docx | PDF to Word |
pdf2imgs | PDF to image |
txt2pdf | Text to PDF |
split4pdf | Split PDF |
encrypt4pdf | Encrypt PDF |
decrypt4pdf | Decrypt PDF |
merge2pdf | Merge PDF |
add_text_watermark | Text watermark |
add_img_water | Image watermark |
add_mark | Watermark (legacy) |
add_watermark_by_parameters | Parameterized watermark |
del4pdf | Delete pages |
add_watermark | Interactive watermark |
pdf2docxโ
office.pdf.pdf2docx(
input_file=None,
output_file=None,
input_path=None,
output_path=None
)
office.pdf.pdf2docx(
input_file='document.pdf',
output_file='document.docx'
)
pdf2imgsโ
office.pdf.pdf2imgs(
input_file=None,
output_file=None,
merge=False
)
office.pdf.pdf2imgs(
input_file='document.pdf',
output_file='./long.png',
merge=True
)
txt2pdfโ
office.pdf.txt2pdf(
input_file='text.txt',
output_file='output.pdf'
)
split4pdfโ
office.pdf.split4pdf(
input_file='big.pdf',
output_file='part1.pdf',
from_page=1,
to_page=10
)
encrypt4pdf / decrypt4pdfโ
# Encrypt
office.pdf.encrypt4pdf(
password='mypassword123',
input_file='document.pdf',
output_file='encrypted.pdf'
)
# Decrypt
office.pdf.decrypt4pdf(
password='mypassword123',
input_file='encrypted.pdf',
output_file='decrypted.pdf'
)
merge2pdfโ
office.pdf.merge2pdf(
input_file_list=['1.pdf', '2.pdf', '3.pdf'],
output_file='merged.pdf'
)
add_text_watermarkโ
office.pdf.add_text_watermark(
input_file='document.pdf',
text='Confidential - For Internal Use Only',
output_file='watermarked.pdf',
fontsize=20,
color=(0, 0, 1)
)
add_img_waterโ
office.pdf.add_img_water(
input_file='document.pdf',
mark_file='logo.png',
output_file='watermarked.pdf'
)
add_markโ
Legacy watermark interface.
office.pdf.add_mark(
input_file='document.pdf',
mark_str='python-office',
output_path='./output/'
)
add_watermark_by_parametersโ
Parameterized watermark (recommended).
office.pdf.add_watermark_by_parameters(
input_file='document.pdf',
mark_str='Confidential',
output_path='./output/',
output_file='watermarked.pdf'
)
del4pdfโ
office.pdf.del4pdf(
input_file='document.pdf',
output_file='deleted.pdf',
page_nums=[1, 3]
)
add_watermarkโ
office.pdf.add_watermark() # Interactive
Related Resourcesโ
- ๐ Usage Guide โ
- ๐ฆ PyPI: popdf
AI ๅๅ
ฌๆ็่ฏพ
35 ่ฎฒ AI ่ชๅจๅๅๅ
ฌๅฎๆ่ฏพ็จ Python + AI ๅค็ ExcelใWordใPDFใ้ฎไปถ็ญๅๅ
ฌๅบๆฏใ
ๅปๅญฆไน