Skip to main content

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

Project description

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()

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

pylibreoffice-0.1.4.tar.gz (64.2 kB view details)

Uploaded Source

File details

Details for the file pylibreoffice-0.1.4.tar.gz.

File metadata

  • Download URL: pylibreoffice-0.1.4.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.0

File hashes

Hashes for pylibreoffice-0.1.4.tar.gz
Algorithm Hash digest
SHA256 46ec94cee84ec58134b06f8046171738c258cb8369d78f014725efb53d307108
MD5 f217a752642a23789235a619058b06e4
BLAKE2b-256 fb764820fd5d3bf40d872e4b8ca0f6a03c2d6b4c88e82fdcbf097b21dfe7615b

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