Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngekoding/office-to-pdf
Convert any office files to pdf format
https://github.com/ngekoding/office-to-pdf
doc-to-pdf document-converter office-to-pdf
Last synced: 2 months ago
JSON representation
Convert any office files to pdf format
- Host: GitHub
- URL: https://github.com/ngekoding/office-to-pdf
- Owner: ngekoding
- Created: 2021-12-17T03:32:39.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T02:44:55.000Z (7 months ago)
- Last Synced: 2024-10-12T07:39:36.791Z (3 months ago)
- Topics: doc-to-pdf, document-converter, office-to-pdf
- Language: PHP
- Homepage: https://packagist.org/packages/ngekoding/office-to-pdf
- Size: 7.81 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# office-to-pdf
Convert any office files to PDF format.
This library use LibreOffice power to convert any office files to PDF format. So, please make sure you have installed LibreOffice on your environment!
## Requirements
- PHP 5.6 or above
- LibreOffice## Installation
```bash
composer require ngekoding/office-to-pdf
```## Usage
### Simple usage
```php
convert('path/to/file.docx');
```You can also convert other file type (not only .docx), feel free to convert any office file like `.pptx`, `.xlsx`, etc...
### Setting process timeout
By default processes have a timeout of 60 seconds, but you can change it passing a different timeout (in seconds) to the `setTimeout()` method:
```php
$converter = new Converter();
$converter->setTimeout(3600);
```Docs: [Symfony Process Timeout](https://symfony.com/doc/3.x/components/process.html#process-timeout)
### Setting manually LibreOffice executable path
By default the library will try to find LibreOffice executable based on current operating system.
```php
$converter = new Converter('path/to/libreoffice');
```### Setting destination folder
By default the PDF result will generated in the same directory as the source file. You can define the destination folder by passing the second parameter.
```php
$converter = new Converter();
$converter->convert('path/to/file.docx', './pdf-outputs');
```By default the PDF filename will same with the source file, you can define the output filename by setting the destination folder with filename.
```php
// The result filename will be result.pdf in the same directory as the source file
$converter->convert('path/to/file.docx', 'result.pdf');// Or save to spesific directory
$converter->convert('path/to/file.docx', './pdf-outputs/result.pdf');
```