PHP code example of blaspsoft / doxswap

1. Go to this page and download the library: Download blaspsoft/doxswap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blaspsoft / doxswap example snippets


'filename' => [
    // Strategy: 'original', 'random', or 'timestamp'
    'strategy' => 'original',

    // Naming options
    'options' => [
        'length' => 24,          // Length for random names
        'prefix' => '',          // Add prefix to filename
        'suffix' => '',          // Add suffix to filename
        'separator' => '_',      // Separator for components
        'format' => 'YmdHis',    // Format for timestamp strategy
    ],
]

'drivers' => [
    'libreoffice_path' => env('LIBRE_OFFICE_PATH', '/usr/bin/soffice'),
]

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

/**
 * Returns a ConversionResult object with the following properties:
 *
 * @property string $inputFilename   The original input filename
 * @property string $inputFilePath   The full path to the input file
 * @property string $outputFilename  The converted output filename
 * @property string $outputFilePath  The full path to the converted output file
 * @property string $toFormat       The format the file was converted to (e.g. 'pdf')
 * @property string $duration       The time taken for conversion (e.g. "2.21 sec")
 * @property float  $startTime      Unix timestamp of when conversion started
 * @property float  $endTime        Unix timestamp of when conversion completed
 * @property string $inputDisk      The Laravel storage disk used for input
 * @property string $outputDisk     The Laravel storage disk used for output
 */

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