https://github.com/markkimsal/dompdf-server
Docker server for converting html to PDF
https://github.com/markkimsal/dompdf-server
docker-compose dompdf pdf-converter php
Last synced: about 2 months ago
JSON representation
Docker server for converting html to PDF
- Host: GitHub
- URL: https://github.com/markkimsal/dompdf-server
- Owner: markkimsal
- License: mit
- Created: 2022-02-12T14:37:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-14T20:54:31.000Z (over 4 years ago)
- Last Synced: 2025-10-10T12:35:50.691Z (8 months ago)
- Topics: docker-compose, dompdf, pdf-converter, php
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# INSTALLATION
run `composer run new-env` to install a new environment.
run `composer run update-versions` to install pre-packaged dompdf releases into vendor_dompdf.
# Usage
POST your HTML to `/convert/html` and get back binary PDF.
```php
'http://localhost:3001',
]);
$payload = file_get_contents('/my-report-or-document.html');
$response = $client->request('POST', '/convert/html', [
'debug' => FALSE,
'multipart' => [
[
'headers' => [
'Content-Type' => 'text/html',
],
'name' => 'my_document',
'filename' => 'my_document.html', // must include filename for laravel/lumen/symfony/php?
'contents' => $payload,
]
]
]);
$body = $response->getBody();
echo $body;
```
# Advanced Usage
You can submit multiple document requests in a single API request, specifying different page orientations
and sizes per document. The resulting documents will be merged with FPDI/FPDF to form one final document.
This is achieved by specifying key,value pairs in the "name" field of the API multipart request. The `name` field
corresponds to the name of the form input if this were coming from an HTML document.
```php
'http://localhost:3001',
]);
$payload = file_get_contents('/my-report-or-document.html');
$response = $client->request('POST', '/convert/html', [
'debug' => FALSE,
'multipart' => [
[
'headers' => [
'Content-Type' => 'text/html',
],
'name' => 'paper=A4,orientation=portrait',
'filename' => 'my_document.html',
'contents' => $payload,
],
[
'headers' => [
'Content-Type' => 'text/html',
],
'name' => 'paper=letter,orientation=landscape',
'filename' => 'my_document_2.html',
'contents' => $payload,
]
]
]);
echo $response->getBody();
```

# SVGs
Dompdf requires that any SVG be base64 encoded and placed into an image tag. This server will
use a regular expression to scan your document for any `` tags and do this automatically.
If the regex fails for you, you can manually bas64 encode your SVGs and place them into an
`
` tag like this:
```
```
# TESTING
`sh ./scripts/test-curl.sh`
or visit
[http://localhost:3001/convert/html](http://localhost:3001/convert/html)