Skip to content

Commit

Permalink
Improve docs (#184)
Browse files Browse the repository at this point in the history
* Explaining `$this->factory->create();`

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
  • Loading branch information
ThomasLandauer authored Jan 10, 2021
1 parent 37fef74 commit b95385c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NucleosDompdfBundle
[![Code Coverage](https://codecov.io/gh/nucleos/NucleosDompdfBundle/branch/main/graph/badge.svg)](https://codecov.io/gh/nucleos/NucleosDompdfBundle)
[![Type Coverage](https://shepherd.dev/github/nucleos/NucleosDompdfBundle/coverage.svg)](https://shepherd.dev/github/nucleos/NucleosDompdfBundle)

This bundle provides a wrapper for using [dompdf] inside symfony.
This bundle provides a wrapper for using [dompdf] inside Symfony.

## Installation

Expand Down Expand Up @@ -53,7 +53,10 @@ final class MyService
public function render()
{
// ...
$this->factory->create();
/** @var Dompdf\Dompdf $dompdf */
$dompdf = $this->factory->create();
// Or pass an array of options:
$dompdf = $this->factory->create(['chroot' => '/home']);
// ...
}
}
Expand All @@ -70,6 +73,7 @@ final class MyOtherService
// ...
$html = '<h1>Sample Title</h1><p>Lorem Ipsum</p>';

/** @var Symfony\Component\HttpFoundation\StreamedResponse $response */
$response = $this->wrapper->getStreamResponse($html, "document.pdf");
$response->send();
// ...
Expand Down Expand Up @@ -98,22 +102,21 @@ $this->wrapper->getStreamResponse($html, 'document.pdf');
### Configure the Bundle

```yaml
# config/packages/nucleos_dompdf.yml
# config/packages/nucleos_dompdf.yaml

nucleos_dompdf:
defaults:
dpi: 150
defaultPaperSize: A4
...
defaultFont: 'helvetica'
# See https://github.com/dompdf/dompdf/wiki/Usage#options for available options
```

### Events

The dompdf wrapper dispatches events to convenient get the inner dompdf instance when creating the pdf.
- `dompdf.output` is dispatched in getPdf
- `dompdf.stream` is dispatched in streamHtml
The dompdf wrapper dispatches events to conveniently get the inner dompdf instance when creating the PDF.
- `dompdf.output` is dispatched in `getPdf()`
- `dompdf.stream` is dispatched in `streamHtml()`

See [Symfony event dispatcher documentation](https://symfony.com/doc/current/event_dispatcher.html) for more info.
See [Symfony Events and Event Listeners](https://symfony.com/doc/current/event_dispatcher.html) for more info.

## License

Expand Down

0 comments on commit b95385c

Please sign in to comment.