Skip to main content

Convert docx to pdf on Windows or macOS directly using Microsoft Word (must be installed). Fork with --hide-markup option to hide comments and revisions.

Project description

docx2pdf

PyPI

Convert docx to pdf on Windows or macOS directly using Microsoft Word (must be installed).

On Windows, this is implemented via win32com while on macOS this is implemented via JXA (Javascript for Automation, aka AppleScript in JS).

Install

On macOS:

brew install aljohri/-/docx2pdf

Via pipx:

pipx install docx2pdf

Via pip:

pip install docx2pdf

CLI

usage: docx2pdf [-h] [--keep-active] [--version] input [output]

Example Usage:

Convert single docx file in-place from myfile.docx to myfile.pdf:
    docx2pdf myfile.docx

Batch convert docx folder in-place. Output PDFs will go in the same folder:
    docx2pdf myfolder/

Convert single docx file with explicit output filepath:
    docx2pdf input.docx output.pdf

Convert single docx file and output to a different explicit folder:
    docx2pdf input.docx output_dir/

Batch convert docx folder. Output PDFs will go to a different explicit folder:
    docx2pdf input_dir/ output_dir/

positional arguments:
  input          input file or folder. batch converts entire folder or convert
                 single file
  output         output file or folder

optional arguments:
  -h, --help     show this help message and exit
  --keep-active  prevent closing word after conversion
  --version      display version and exit

Library

from docx2pdf import convert

convert("input.docx")
convert("input.docx", "output.pdf")
convert("my_docx_folder/")

See CLI docs above (or in docx2pdf --help) for all the different invocations. It is the same for the CLI and python library.

Jupyter Notebook

If you are using this in the context of jupyter notebook, you will need ipywidgets for the tqdm progress bar to render properly.

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

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

docx2pdf_markup-0.1.9.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

docx2pdf_markup-0.1.9-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file docx2pdf_markup-0.1.9.tar.gz.

File metadata

  • Download URL: docx2pdf_markup-0.1.9.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docx2pdf_markup-0.1.9.tar.gz
Algorithm Hash digest
SHA256 f264edfbd6aad81210106181454887c42b198b354eca064303b2281c9734f715
MD5 5fcb2ad02a7b7fc484540e490a04a42a
BLAKE2b-256 6a667a4791ff12707c951bf083cf90f62684c79e4f6fc0127eae3207dc32fd43

See more details on using hashes here.

File details

Details for the file docx2pdf_markup-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for docx2pdf_markup-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 46c4fcac4307e0c4e12b038e160c848a6d6f668f29a4273adbb852f632e0e03b
MD5 4e9864bccdfd72662b3031bde92a7be9
BLAKE2b-256 6bab508c57ede79ab97f6c30ea4490eb7fd66bbb35d94ea2584b0e38c806b13c

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