Created
April 27, 2024 07:01
-
-
Save documentprocessing/5dc51f747fda04dca2f65e56501f0303 to your computer and use it in GitHub Desktop.
Convert specific PDF pages to DOCX using pdf2docx API in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pdf2docx import Converter | |
# PDF file to be converted | |
pdf_file = 'example.pdf' | |
# Output DOCX file | |
docx_file = 'output.docx' | |
# Create a PDF to DOCX converter object | |
cv = Converter(pdf_file) | |
# Convert pages 5 to 10 (note that page indices start from 0, so adjust accordingly) | |
cv.convert(docx_file, start=4, end=10) # This will convert pages 5 to 9 | |
# Close the converter when done | |
cv.close() | |
print("Conversion of specific pages completed! The DOCX file has been created.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment