Skip to main content

pylibreoffice

A Python library for handling Microsoft Office documents, built with LibreOfficeKit.

Features

  • Convert Microsoft Office documents to PDF

Installation

Requirements

  • Python 3.10 or higher

  • LibreOffice 7.2 or higher

sudo apt-get install -y libreoffice libreoffice-dev libreoffice-dev-doc
  • The fonts used in the document must be installed on the system.For example,use Chinese, on Ubuntu, you can install the fonts by running the following command:
sudo apt-get install -y fonts-wqy-zenhei fonts-wqy-microhei xfonts-intl-chinese ttf-wqy-zenhei ttf-wqy-microhei language-pack-zh-hans language-pack-zh-hant && \
sudo dpkg-reconfigure locales && \
sudo update-locale LANG=zh_CN.UTF-8
pip install pylibreoffice

Example

from pylibreoffice.core import PyOffice


class Example:
    def __init__(self):
        self.office = PyOffice("/usr/lib/libreoffice/program/")

    def doc(self):
        # Convert the doc file to pdf
        print(self.office.save_as("./test.doc", "./test.pdf", "pdf"))

    def xls(self):
        # Convert the xls file to pdf
        print(self.office.save_as("./test.xls", "./test_xls.pdf", "pdf"))


if __name__ == '__main__':
    ex = Example()
    ex.xls()
    ex.doc()

Release files for pylibreoffice 0.1.4

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

Source distribution (sdist)

Source distribution for pylibreoffice 0.1.4
File Size Uploaded
pylibreoffice-0.1.4.tar.gz 64.2 kB Details

Release files / pylibreoffice-0.1.4.tar.gz

Download URL pylibreoffice-0.1.4.tar.gz
Size 64.2 kB
Tags Source
SHA-256 checksum
How to use checksums
46ec94cee84ec58134b06f8046171738c258cb8369d78f014725efb53d307108
BLAKE2b-256 checksum
How to use checksums
fb764820fd5d3bf40d872e4b8ca0f6a03c2d6b4c88e82fdcbf097b21dfe7615b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

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