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.py_office 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.2.tar.gz (66.9 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pylibreoffice-0.1.2.tar.gz
Algorithm Hash digest
SHA256 df270b499ff160cdd5527aa92cced407c53d429dd1e94bc63458fbbebaed15f2
MD5 9ff702feff6cf01ac00cc112e89391fc
BLAKE2b-256 99f5aa52a9c3ccf98b7fc090e1121f196da8c34e01bc27de9d49b3cafc48dc51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page