Skip to main content

Python library and CLI for converting PDF files to DOCX.

Project description

docx-from-pdf

A Python library and CLI for converting PDF files into editable DOCX documents.

docx-from-pdf uses PDFium for PDF parsing and rendering. It converts text, tables, images, vector paths, and section layout into DOCX output with permissive runtime dependencies.

This project uses PDFium through pypdfium2; it is not affiliated with PDFium, Chromium, or Google.

Install

Install from PyPI:

pip install docx-from-pdf

Install from source:

pip install git+https://github.com/michael-provision/docx-from-pdf.git

Install local development dependencies:

uv venv
uv pip install -r requirements.txt

Usage

Convert a PDF from Python:

from docx_from_pdf import Converter

converter = Converter("input.pdf")
converter.convert("output.docx")
converter.close()

Convert a PDF from the CLI:

docx-from-pdf convert input.pdf output.docx

Extract tables:

from docx_from_pdf import Converter

converter = Converter("input.pdf")
tables = converter.extract_tables()
converter.close()

Development

Run the test suite:

PYTHONPATH=. uv run --no-project --with-requirements requirements.txt --with pytest pytest -q test/test.py

Some visual-comparison tests render DOCX files through LibreOffice on non-Windows systems, so LibreOffice must be installed for the full suite.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docx_from_pdf-0.1.tar.gz (18.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docx_from_pdf-0.1-py3-none-any.whl (124.3 kB view details)

Uploaded Python 3

File details

Details for the file docx_from_pdf-0.1.tar.gz.

File metadata

  • Download URL: docx_from_pdf-0.1.tar.gz
  • Upload date:
  • Size: 18.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docx_from_pdf-0.1.tar.gz
Algorithm Hash digest
SHA256 8c35c6703bb29e9ba83d059dea17b790a673aa408162b06b9f3bcfd662442df0
MD5 e5b56b3644b0aa37355fdfcfbac9c0b8
BLAKE2b-256 c698228238a858ac8d6961fb3b9c9a415a9264f951550ef04ff34bf87aba35d7

See more details on using hashes here.

File details

Details for the file docx_from_pdf-0.1-py3-none-any.whl.

File metadata

  • Download URL: docx_from_pdf-0.1-py3-none-any.whl
  • Upload date:
  • Size: 124.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docx_from_pdf-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 044297cf484afa964569a218256619635bcd1e8ee54e2e17177a25664ca011ac
MD5 2a2a67f2c6de96baa026e28db6674fd1
BLAKE2b-256 194360582e1355874dc942bd0638ce5b753e46200b8f4a2686a0688c605afd9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page