Skip to main content

A zero-dependency DOCX to PDF converter using only the Python Standard Library.

Project description

docx_to_pdf_native (High-Fidelity Converter)

A powerful, zero-dependency Python package to convert .docx documents (invoices, reports, resumes) to high-quality .pdf files using only the Python Standard Library.

Key Features

  • Zero Third-Party Dependencies: No pip install requirements other than this package. Built using only built-in modules (zipfile, xml, zlib).
  • High-Fidelity Rendering:
    • Bold, Italic, and Highlights: Preserves inline styling from Word documents.
    • Precision Word Wrapping: Intelligent layout engine using font metrics for accurate line breaks.
    • Image Extraction: Automatically embeds images (JPEG/PNG) from the DOCX at their original dimensions.
    • Tables: Renders borders and layouts structured data, ideal for invoices.
    • Bullet Points: Supports numbered and bulleted lists with proper indentation.
  • Advanced Engine:
    • Unicode Support: Safely handles non-ASCII characters (like smart quotes, em-dashes, and currency symbols) via CP1252 encoding.
    • Multi-Page Support: Automatic pagination and page-break management.
    • Native PDF Generation: Independently constructs the binary PDF structure (Xref tables, font dictionaries, and trailers).

Installation

Since this is a zero-dependency project, you can simply include the folder in your project or install it via pip:

pip install .

Usage

Command Line

docx2pdf-native path/to/input.docx output.pdf

Python API

from docx_to_pdf_native import DocxToPdfConverter

converter = DocxToPdfConverter("invoice.docx", "invoice.pdf")
converter.convert()

Production Reliability

  • Isolated: No risk of dependency conflicts in your server environment.
  • Fast: Performs direct XML-to-binary conversion without spawning sub-processes or browser instances.
  • Stand-alone: Perfect for Dockerized microservices or serverless functions (AWS Lambda, etc.).

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_to_pdf_native-0.1.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

docx_to_pdf_native-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docx_to_pdf_native-0.1.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for docx_to_pdf_native-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c9fc155b2c777d5133f4c4ba48b8a251a93b5d0eefe801cb887c6b165857c87b
MD5 7a15f9f35a9c989edcfd01a4fa3f6b2e
BLAKE2b-256 61864401c16d1e3d8e8493ebe47cc881709b2c57c72be823d3faf662d6f5683a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docx_to_pdf_native-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe6f38bc25b68da60d3372c47d8f436c41a3a5e41649d699eac00dfb98eb2ed
MD5 af6dbebd8cf56a5b077cca40b2d33539
BLAKE2b-256 a1b6eb2033914dd103c40234c377626b12a24afefc8c4e5aaf484831f767d105

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