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.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.1-py3-none-any.whl (124.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docx_from_pdf-0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d36328fbbaa7b825fb36d0b7683dda66a8f1bdfbf2847e77a7eaee404165d35e
MD5 fb446d442d80644b878add59f57780f2
BLAKE2b-256 43a088422013828653b05979725a6d3f62a9ae90222392ecf3950c420f2761b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: docx_from_pdf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 124.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7beb030362f5edece502c9157cd2529d90f35f905e04993d4b6fcda1c793d0a
MD5 c5eadd5b51b4dfe855e589e3bd740859
BLAKE2b-256 52f9da8e1d42c2e39a5fd637713072fd8c90a4ad6567e5b1877cddcc66a16548

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