https://github.com/smnandre/pandoc
Pandoc PHP - Advanced Document Converter
https://github.com/smnandre/pandoc
converter convertion document docx html latex markdown pandoc pandoc-php pdf php-cli php-library rst symfony-console
Last synced: about 2 months ago
JSON representation
Pandoc PHP - Advanced Document Converter
- Host: GitHub
- URL: https://github.com/smnandre/pandoc
- Owner: smnandre
- License: mit
- Created: 2024-12-24T04:36:35.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-03T01:06:52.000Z (4 months ago)
- Last Synced: 2025-04-14T19:07:29.702Z (about 2 months ago)
- Topics: converter, convertion, document, docx, html, latex, markdown, pandoc, pandoc-php, pdf, php-cli, php-library, rst, symfony-console
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Pandoc PHP - Advanced Document Converter
Markdown - HTML - PDF - DOCX - RST - LaTeX - Reveal Slides
[](https://github.com/smnandre/pandoc/blob/main/composer.json)
[](https://github.com/smnandre/pandoc/actions)
[](https://github.com/smnandre/pandoc/releases)
[](https://github.com/smnandre/pandoc/blob/main/LICENSE)
[](https://codecov.io/gh/smnandre/pandoc)This PHP library offers a modern PHP wrapper for the [Pandoc](https://pandoc.org/) document converter.
## Installation
```bash
composer require smnandre/pandoc
```## Basic Usage
### Convert single file
```php
use Pandoc\Options;
use Pandoc\Pandoc;
use Symfony\Component\Finder\Finder;// 1. Convert a single file with options:
$options = Options::create()
->setInput(['input.md'])
->setOutput('output.pdf')
->setFormat('pdf')
->tableOfContent();Pandoc::create()->convert($options);
```### Convert multiple files using Finder
```php
$finder = Finder::create()->files()->in('docs')->name('*.md');
$options = Options::create()
->setInput($finder)
->setOutputDir('output')
->setFormat('html');Pandoc::create()->convert($options);
## Options
### Default Options
```php
$defaultOptions = Options::create()
->setFormat('html')
->tableOfContent();$pandoc = Pandoc::create(defaultOptions: $defaultOptions);
```### Override default options
Use default options, override output for this specific file:
```php
$options = Options::create()->setInput(['chapter1.md'])->setOutput('chapter1.html');
$pandoc->convert($options);
```### Advanced Options
```php
$defaultOptions = Options::create()
->setInput(Finder::create()->files()->in('docs')->name('*.md'))
->setOutputDir('output')
->setFormat('html');
$pandoc = Pandoc::create(null, $defaultOptions);
$pandoc->convert(Options::create()); // Will use default options
```## Input / Output
### Default Output
```php
$options = Options::create()
->setInput(['input.md'])
->setFormat('html')
->tableOfContent();
Pandoc::create()->convert($options);
```## Technical Details
### Formats
* list input formats
* list output formats## Resources
### Pandoc
* https://pandoc.org/
* https://pandoc.org/MANUAL.html### Pandoc Docker
* https://github.com/pandoc/dockerfiles
* https://github.com/dalibo/pandocker### GitHub Actions
* https://github.com/pandoc/actions/tree/main/setup
Any contribution is welcome!
### Suggestions
You can suggest new features or improvements by [opening an RFC](https://github.com/smnanre/pandoc/issues/new)
or a [Pull Request](https://github.com/smnanre/pandoc/issues/new) on the GitHub repository of **Pandoc PHP**.### Issues
If you encounter any issues, please [open an issue](https://github.com/smnanre/pandoc/issues/new) on the GitHub
repository of **Pandoc PHP**.### Testing
Before submitting a Pull Request, make sure to run the following commands, and that they all pass.
If you have any questions, feel free to ask on the [GitHub repository](https://github.com/smandre/pandoc) of **Pandoc PHP**.
```bash
php vendor/bin/php-cs-fixer check
php vendor/bin/phpstan analyse
php vendor/bin/phpunit
```[Pandoc PHP](https://github.com/smnandre/pandoc) is maintained by [Simon André](https://github.com/smnandre)
Pandoc is a project by [John MacFarlane](https://johnmacfarlane.net/) and contributors.## Contributing
## Credits
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.