easyofd Documentation

repository·master·Indexed 19 days ago

https://github.com/renoyuan/easyofd

A Python library for parsing and converting OFD (Open Formatted Document) files. It supports conversions between OFD, PDF, and image formats (JPG), and includes a GUI tool for performing these operations.

Tokens
744
Snippets
3
Records
6
Agent score
16%

What's inside easyofd

  1. Use easyofd for OFD conversions

    master

    The library provides capabilities for parsing OFD files and performing various format conversions.

    Supported features include:

    • Parsing OFD files
    • OFD to PDF or Image conversion
    • PDF to OFD or Image conversion
    • JPG to OFD or PDF conversion
    • GUI tools for the above operations

    For comprehensive usage examples covering all available functions, refer to the test/demo.py file in the repository.

    # Refer to test/demo.py for complete implementation examples
  2. Supported conversion modes in easyofd GUI

    master

    The GUI provides radio buttons to select one of the following conversion modes:

    • ofd2pdf: Converts OFD files to PDF.
    • ofd2img: Converts OFD files to JPG images.
    • pdf2ofd: Converts PDF files to OFD.
    • pdf2img: Converts PDF files to JPG images.
    • img2ofd: (Placeholder) Converts images to OFD.
    • img2pdf: (Placeholder) Converts images to PDF.

    Users must provide an Input Path (directory containing source files) and an Output Path (directory where converted files will be saved).

  3. Internal file processing logic for conversions

    master

    The GUI uses the following internal logic to handle file data before passing it to the easyofd.OFD engine:

    • OFD Reading: OFD files are read from disk and encoded into a Base64 UTF-8 string before being passed to self.ofd.read(ofdb64).
    • PDF Reading: PDF files are read as raw bytes and passed to self.ofd.pdf2ofd(pfdbyte) or self.ofd.pdf2img(pfdbyte).
    • File Saving:
      • For PDF/OFD outputs, the raw bytes are written directly to the destination file.
      • For Image outputs, the system iterates through the image objects and saves them using a formatted filename (e.g., filename_{index}.jpg).
  4. Run the easyofd GUI

    master

    The gui/main.py file serves as the entrypoint for the graphical user interface. It provides a visual way to perform OFD conversions using the easyofd library. The GUI supports several conversion modes including OFD to PDF, OFD to Image, PDF to OFD, and PDF to Image.

    To run the GUI, ensure you have the necessary dependencies installed (specifically PyQt6 and Pillow) and execute the script using Python.

    python gui/main.py
  5. Troubleshooting and FAQ

    master

    Before submitting an issue, please consult the following resources:

    1. FAQ: For common questions regarding installation, usage, and handling missing font packages on Linux systems, visit the official FAQ wiki.
    2. Issue Guidelines: Read the Issue Submission Guide before opening a new issue.
    3. Reporting Parsing Errors: If an OFD file fails to parse, the author requests that you send the file via email (since GitHub does not support OFD uploads). It is recommended to package the OFD file into a .tar archive before sending.