PhpLibre is an integration library for the file conversion functionality of LibreOffice.
In order to use this library, you'll need LibreOffice installed. You can find it at the Libre Office Website or you can install it through Homebrew with brew install --cask libreoffice
PhpLibre can be installed to your project via Composer by adding the following line to your composer.json file:
"cidilabs/phplibre": "dev-master"
Once LibreOffice and the PhpLibre library are installed, you'll need to let UDOIT know which file conversion library you'll be using.
This can be done:
- In the .env:
###> file formats ### AVAILABLE_FILE_FORMATS="html,pdf" HTML_FILE_FORMAT_CLASS="\\CidiLabs\\PhpLibre\\PhpLibre" PDF_FILE_FORMAT_CLASS="\\CidiLabs\\PhpLibre\\PhpLibre"
Where AVAILABLE_FILE_FORMATS
is the list of formats that files can be converted to, and for each of those formats there is a {FORMAT}_FILE_FORMAT_CLASS
field that points to PhpLibre.
- fileName: The name of the file
- fileUrl: The download URL for the file
- fileType: The file type of the original file
- format: The file type that we want to convert to
$libre = new PhpLibre();
$fileUrl = "https://cidilabs.instructure.com/files/295964/download?download_frd=1&verifier=RZwKCP3iVlNQIULZnTAXO0usUROMC9AuplKkDf2g";
$options = array('fileUrl' => $fileUrl, 'fileType' => 'pdf', 'format' => 'html', 'fileName' => 'Test1.pdf');
$libre->convertFile($options);
- options: (array) -- fileName: (string) The name of the file -- fileUrl: (string) The download URL for the file -- fileType: (string) The file type of the original file -- format: (string) The file type that we want to convert to
- taskId: (string) The UUID representing the file conversion task
- null
- taskId: (string) The UUID representing the file conversion task
- True/False (boolean) True if the file has been converted and is ready, false otherwise
- taskId: (string) The UUID representing the file conversion task
- fileUrl: (string) The url of the converted file
- null
- fileUrl: (string) The url of the converted file
(To Do)
- fileUrl: (string) The url of the converted file
- True/False (boolean) True if successfully deleted, false otherwise