Skip to main content

msoffice2pdf

Python Flask

This package aims to convert Microsoft Office file types to PDF. This lib uses the comtypes package which makes it easy to access and implement custom, dispatch-based COM interfaces or LibreOffice software.

Prerequisites

Python >=3.6 installed on the environment.

Installation

Step 1:

pip3 install msoffice2pdf

Step 2

(Windons Only):

For Microsoft Office use:

  • Delete all cache files from the folder below in case there is any error with Microsoft Office conversion: C:\Users\<User>\AppData\Local\Programs\Python\Python39\Lib\site-packages\comtypes\gen

  • For Windows Server

Step 1:

Start > Run > dcomcnfg.exe

Step 2:

Select: Computers -> My Computer -> Config DCOM -> Microsoft Word 97-2003 Documents -> Properties Tab general select level authentication to None Tab security select customize and add All Tab identify select this user and add Admin user and password

Step 3:

Select: Computers -> My Computer -> Config DCOM -> Microsoft Excel Application -> Properties Tab general select level authentication to None Tab security select customize and add All Tab identify select this user and add Admin user and password

Step 4:

Select: Computers -> My Computer -> Config DCOM -> Microsoft PowerPoint Application -> Properties Tab general select level authentication to None Tab security select customize and add All Tab identify select this user and add Admin user and password

For LibreOffice use:

Install LibreOffice last version:

https://www.libreoffice.org/download/download/

(Ubuntu Only):

Install LibreOffice:

sudo add-apt-repository -y ppa:libreoffice/ppa

sudo apt-get update

sudo apt-get install libreoffice libreoffice-style-breeze

Example:

For use in Windows environment and soft=0 Microsoft Office must be installed.

For use in Windows environment and soft=1 you need the latest version of LibreOffice(soffice) installed.

For Ubuntu(linux) environment it is only possible to use soft=1, that is, LibreOffice(soffice).

Supported files: [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".xml"]

from msoffice2pdf import convert

output = convert(source="C:/Users/<User>/Downloads/file.docx", output_dir="C:/Users/<User>/Downloads", soft=0)

print(output)

Release files for msoffice2pdf 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for msoffice2pdf 1.0.0
File Interpreter ABI Platform
msoffice2pdf-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / msoffice2pdf-1.0.0-py3-none-any.whl

Download URL msoffice2pdf-1.0.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
450505aedb027ed530a5d8d5ac5c0de046141f5256d41198434be21a95da99c5
BLAKE2b-256 checksum
How to use checksums
c2413214ef12bd4009db82654f5f52b82cde9bb241996415c4acde56319a590f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page