Skip to content

Doxswap is a Laravel package for seamless document conversion using LibreOffice. Effortlessly convert DOCX, PDF, ODT, and more with a simple, elegant API. Supports Laravel storage, configurable settings, and secure file handling.

License

Notifications You must be signed in to change notification settings

Blaspsoft/doxswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Onym Icon

GitHub Workflow Status (main) Total Downloads Latest Version License

Doxswap

A Laravel package for seamless document conversion using LibreOffice. Convert between various document formats like DOCX, PDF, ODT and more with a simple, elegant API.

πŸš€ Features

  • πŸ“„ Multiple Format Support – Convert between DOCX, PDF, ODT, and other document formats.
  • πŸš€ Simple API – Easy-to-use interface for document conversion operations.
  • πŸ’Ύ Laravel Storage Integration – Works seamlessly with Laravel's filesystem drivers.
  • ⚑ Efficient Processing – Optimized conversion using LibreOffice's powerful engine.
  • πŸ”’ Secure File Handling – Safe and secure document processing with proper cleanup.
  • βš™οΈ Configurable Settings – Customize paths, storage disks, and conversion options.
  • πŸ›‘οΈ Error Handling – Robust exception handling for unsupported formats and conversions.

Installation

You can install the package via composer:

composer require blaspsoft/doxswap:0.1.0-beta

You can publish the config file with:

php artisan vendor:publish --tag="doxswap-config"

Overview

The config/doxswap.php file includes:

πŸ’Ύ Storage

  • input_disk: Where to read files from (default: 'public')
  • output_disk: Where to save converted files (default: 'public')
  • perform_cleanup: Delete input files after conversion (default: false)

πŸ› οΈ LibreOffice Path

'libre_office_path' => env('LIBRE_OFFICE_PATH', '/usr/bin/soffice')

Default paths by OS:

  • 🐧 Linux: /usr/bin/soffice
  • 🍎 macOS: /Applications/LibreOffice.app/Contents/MacOS/soffice
  • πŸͺŸ Windows: C:\Program Files\LibreOffice\program\soffice.exe

πŸ“„ File Types

Supports various document formats including:

  • Documents: DOC, DOCX, ODT, RTF, TXT
  • Spreadsheets: XLS, XLSX, ODS, CSV
  • Presentations: PPT, PPTX, ODP
  • Images: JPG, PNG, SVG, BMP, TIFF
  • Web: HTML, XML
  • Other: PDF, EPUB

Usage

$convertedFile = Doxswap::convert('sample.docx', 'pdf');

/**
 * Returns a Doxswap object with the following properties:
 *
 * @property string $inputFile      The original input filename
 * @property string $outputFile     The full path to the converted output file
 * @property string $toFormat      The format the file was converted to (e.g. 'pdf')
 * @property ConversionService $conversionService  The service used for conversion
 */

Requirements

LibreOffice

This package requires LibreOffice to be installed on your system. Here's how to install it:

Ubuntu/Debian

sudo apt update
sudo apt install libreoffice

macOS

brew install libreoffice

Windows

choco install libreoffice

Docker

If you're using Docker, you can add LibreOffice to your container:

# Ubuntu/Debian based
RUN apt-get update && apt-get install -y libreoffice

# Alpine based
RUN apk add --no-cache libreoffice

PHP Requirements

  • PHP >= 8.1
  • ext-fileinfo
  • Laravel >= 9.0

Supported Conversions πŸ“„ ↔️ πŸ“‘

From/To PDF DOCX ODT RTF TXT HTML EPUB XML XLSX ODS CSV PPT PPTX ODP PNG JPG SVG TIFF
DOC βœ… βœ… βœ… βœ… βœ… βœ… βœ… βœ…
DOCX βœ… βœ… βœ… βœ… βœ… βœ… βœ…
ODT βœ… βœ… βœ… βœ… βœ… βœ… βœ…
RTF βœ… βœ… βœ… βœ… βœ… βœ…
TXT βœ… βœ… βœ… βœ… βœ…
HTML βœ… βœ… βœ…
XML βœ… βœ… βœ… βœ… βœ…
CSV βœ… βœ… βœ… βœ…
XLSX βœ… βœ… βœ… βœ…
XLS βœ… βœ… βœ… βœ…
ODS βœ… βœ… βœ… βœ…
PPTX βœ… βœ…
PPT βœ… βœ…
ODP βœ… βœ…
SVG βœ… βœ… βœ… βœ…
JPG βœ… βœ… βœ…
PNG βœ… βœ… βœ…
BMP βœ… βœ… βœ…
TIFF βœ… βœ… βœ…

Legend πŸ”

  • βœ… : Supported conversion
  • Empty cell: Conversion not supported

File Type Categories πŸ“

  • πŸ“ Documents: DOC, DOCX, ODT, RTF, TXT
  • 🌐 Web: HTML, XML
  • πŸ“Š Spreadsheets: XLSX, XLS, ODS, CSV
  • 🎯 Presentations: PPT, PPTX, ODP
  • πŸ–ΌοΈ Images: SVG, JPG, PNG, BMP, TIFF
  • πŸ“š eBooks: EPUB
  • πŸ“„ Universal: PDF

Note: All conversions are performed using LibreOffice in headless mode πŸš€

License

Blasp is open-sourced software licensed under the MIT license.

About

Doxswap is a Laravel package for seamless document conversion using LibreOffice. Effortlessly convert DOCX, PDF, ODT, and more with a simple, elegant API. Supports Laravel storage, configurable settings, and secure file handling.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages