Skip to main content

Пакет для работы с .docx файлами

Project description

DocxP

DocxP — это мой небольшой Python-проект для создания и форматирования Word-документов с использованием библиотеки python-docx. Вы можете дополнять и расширять ее при необходимости. Я постарался построить гибкую основу для последующего расширения.

Возможности

  • Абстрактные классы для описания стилей документа, абзацев и текста.
  • Реализация базовых стилей и логики генерации Word-документов.
  • Гибкая настройка шрифтов, отступов, выравнивания и др.

Структура проекта

  • core/ — модуль с основными и абстрактными классами:
    • AbstractClasses.py — абстрактные интерфейсы
    • CoreClasses.py — реализация базовых стилей
    • CustomClasses.py — расширение с пользовательскими стилями

Установка

pip install python-docx py_docx_creator

Пример использования

from py_docx_creator.CoreClasses import CoreDocumentCreator
from py_docx_creator.CustomClasses import MainPageFormat, MainDocumentWriter, HeaderParagraphFormat, MainTextStyle, \
    MainParagraphFormat


class DocumentAPI(CoreDocumentCreator):

    def __init__(self, file_name: str):
        super().__init__()
        self.file_name = file_name

    def run(self):
        self.create_document(self.file_name)
        MainPageFormat().apply_style(document=self.document)
        paragraph = MainDocumentWriter.add_paragraph_to_document(self.document)
        HeaderParagraphFormat().apply_style(paragraph=paragraph)
        run = MainDocumentWriter.add_run_to_paragraph(paragraph=paragraph, text="Какой либо текст")
        MainTextStyle().apply_style(run=run)

        paragraph = MainDocumentWriter.add_paragraph_to_document(self.document)
        MainParagraphFormat().apply_style(paragraph=paragraph)
        run = MainDocumentWriter.add_run_to_paragraph(paragraph=paragraph, text="Какой либо текст")
        MainTextStyle().apply_style(run=run)
        self.save_document()


if __name__ == '__main__':
    
    DocumentAPI("Документ.docx").run()

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

py_docx_creator-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

py_docx_creator-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file py_docx_creator-0.1.0.tar.gz.

File metadata

  • Download URL: py_docx_creator-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for py_docx_creator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0fdedb95184ae86984dce55dac3dc98ddb6c8a4220b6deafb526c342ffb4419a
MD5 d213f3765564d8573209c567cdfa6dcd
BLAKE2b-256 01e2c3917a57424e257d1799e9da8181136912e1351b52fa95ac7186413ac164

See more details on using hashes here.

File details

Details for the file py_docx_creator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_docx_creator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ce60d783e24b39c43b968932719e811dea57f919bc823b6923a66a5a1024623
MD5 ca5c6a65ade0d66141a764aff6bc54ba
BLAKE2b-256 147a6a60ba031f138e1136a85cc3fd6f593447a664db917b5cffb36521e3ba7b

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