{"id":19630986,"url":"https://github.com/nucleos/nucleosdompdfbundle","last_synced_at":"2025-04-03T03:10:07.012Z","repository":{"id":37081364,"uuid":"44382904","full_name":"nucleos/NucleosDompdfBundle","owner":"nucleos","description":"📜 This bundle provides a wrapper for using dompdf inside symfony.","archived":false,"fork":false,"pushed_at":"2024-05-22T12:37:17.000Z","size":1413,"stargazers_count":34,"open_issues_count":5,"forks_count":13,"subscribers_count":3,"default_branch":"4.3.x","last_synced_at":"2024-05-22T13:33:13.086Z","etag":null,"topics":["bundle","dompdf","hacktoberfest","pdf","php","symfony","symfony-bundle","wrapper"],"latest_commit_sha":null,"homepage":"https://nucleos.rocks","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nucleos.png","metadata":{"funding":{"github":"core23","open_collective":"core23","ko_fi":"core23","custom":"https://donate.core23.de"},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-16T12:15:29.000Z","updated_at":"2024-06-19T09:57:07.786Z","dependencies_parsed_at":"2024-06-19T09:57:05.379Z","dependency_job_id":"45ab15ee-cc23-4d3b-ae42-d612c9425c04","html_url":"https://github.com/nucleos/NucleosDompdfBundle","commit_stats":{"total_commits":749,"total_committers":14,"mean_commits":53.5,"dds":"0.49399198931909216","last_synced_commit":"a2599a475c57220e14672a33ee222bcb08412672"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nucleos%2FNucleosDompdfBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nucleos%2FNucleosDompdfBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nucleos%2FNucleosDompdfBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nucleos%2FNucleosDompdfBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nucleos","download_url":"https://codeload.github.com/nucleos/NucleosDompdfBundle/tar.gz/refs/heads/4.3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927835,"owners_count":20856198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","dompdf","hacktoberfest","pdf","php","symfony","symfony-bundle","wrapper"],"created_at":"2024-11-11T12:07:20.921Z","updated_at":"2025-04-03T03:10:06.968Z","avatar_url":"https://github.com/nucleos.png","language":"PHP","funding_links":["https://github.com/sponsors/core23","https://opencollective.com/core23","https://ko-fi.com/core23","https://donate.core23.de"],"categories":[],"sub_categories":[],"readme":"NucleosDompdfBundle\n===================\n[![Latest Stable Version](https://poser.pugx.org/nucleos/dompdf-bundle/v/stable)](https://packagist.org/packages/nucleos/dompdf-bundle)\n[![Latest Unstable Version](https://poser.pugx.org/nucleos/dompdf-bundle/v/unstable)](https://packagist.org/packages/nucleos/dompdf-bundle)\n[![License](https://poser.pugx.org/nucleos/dompdf-bundle/license)](LICENSE.md)\n\n[![Total Downloads](https://poser.pugx.org/nucleos/dompdf-bundle/downloads)](https://packagist.org/packages/nucleos/dompdf-bundle)\n[![Monthly Downloads](https://poser.pugx.org/nucleos/dompdf-bundle/d/monthly)](https://packagist.org/packages/nucleos/dompdf-bundle)\n[![Daily Downloads](https://poser.pugx.org/nucleos/dompdf-bundle/d/daily)](https://packagist.org/packages/nucleos/dompdf-bundle)\n\n[![Continuous Integration](https://github.com/nucleos/NucleosDompdfBundle/actions/workflows/continuous-integration.yml/badge.svg?event=push)](https://github.com/nucleos/NucleosDompdfBundle/actions?query=workflow%3A\"Continuous+Integration\"+event%3Apush)\n[![Code Coverage](https://codecov.io/gh/nucleos/NucleosDompdfBundle/graph/badge.svg)](https://codecov.io/gh/nucleos/NucleosDompdfBundle)\n[![Type Coverage](https://shepherd.dev/github/nucleos/NucleosDompdfBundle/coverage.svg)](https://shepherd.dev/github/nucleos/NucleosDompdfBundle)\n\nThis bundle provides a wrapper for using [dompdf] inside Symfony.\n\n## Installation\n\nOpen a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:\n\n```\ncomposer require nucleos/dompdf-bundle\n```\n\n### Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles in `config/bundles.php` file of your project:\n\n```php\n// config/bundles.php\n\nreturn [\n    // ...\n    Nucleos\\DompdfBundle\\NucleosDompdfBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Configure the Bundle\n\n```yaml\n# config/packages/nucleos_dompdf.yaml\n\nnucleos_dompdf:\n    defaults:\n        defaultFont: 'helvetica'\n        # See https://github.com/dompdf/dompdf/wiki/Usage#options for available options\n```\n\n## Usage\n\nWhenever you need to turn a html page into a PDF use dependency injection for your service:\n\n```php\nuse Nucleos\\DompdfBundle\\Factory\\DompdfFactoryInterface;\nuse Nucleos\\DompdfBundle\\Wrapper\\DompdfWrapperInterface;\n\nfinal class MyService\n{\n    public function __construct(DompdfFactoryInterface $factory)\n    {\n        $this-\u003efactory = $factory;\n    }\n\n    public function render()\n    {\n        // ...\n        /** @var Dompdf\\Dompdf $dompdf */\n        $dompdf = $this-\u003efactory-\u003ecreate();\n        // Or pass an array of options:\n        $dompdf = $this-\u003efactory-\u003ecreate(['chroot' =\u003e '/home']);\n        // ...\n    }\n}\n\nfinal class MyOtherService\n{\n    public function __construct(DompdfWrapperInterface $wrapper)\n    {\n        $this-\u003ewrapper = $wrapper;\n    }\n\n    public function stream()\n    {\n        // ...\n        $html = '\u003ch1\u003eSample Title\u003c/h1\u003e\u003cp\u003eLorem Ipsum\u003c/p\u003e';\n\n        /** @var Symfony\\Component\\HttpFoundation\\StreamedResponse $response */\n        $response = $this-\u003ewrapper-\u003egetStreamResponse($html, \"document.pdf\");\n        $response-\u003esend();\n        // ...\n    }\n\n    public function binaryContent()\n    {\n        // ...\n        return $this-\u003ewrapper-\u003egetPdf($html);\n        // ...\n    }\n}\n```\n### Render pdf using Twig\n\nIf you use Twig to create the content, make sure to use `renderView()` instead of `render()`.\nOtherwise you might get the following HTTP header printed inside your PDF:\n\u003e HTTP/1.0 200 OK Cache-Control: no-cache\n\n```php\n$html = $this-\u003erenderView('my_pdf.html.twig', array(\n    // ...\n));\n$this-\u003ewrapper-\u003egetStreamResponse($html, 'document.pdf');\n```\n\n### Using asset() to link assets\n\n\nFirst, make sure your `chroot` is correctly set and `isRemoteEnabled` is true.\n\n```yaml\n# config/packages/nucleos_dompdf.yaml\n\nnucleos_dompdf:\n    defaults:\n        chroot: '%kernel.project_dir%/public/assets'\n        isRemoteEnabled: true\n```\n\nSecond, use `{{ absolute_url( asset() ) }}`\n\n```html\n\u003cimg src={{ absolute_url( asset('assets/example.jpg') ) }}\u003e\n```\n\n### Events\n\nThe dompdf wrapper dispatches events to conveniently get the inner dompdf instance when creating the PDF.\n- `dompdf.output` is dispatched in `getPdf()`\n- `dompdf.stream` is dispatched in `streamHtml()`\n\nSee [Symfony Events and Event Listeners](https://symfony.com/doc/current/event_dispatcher.html) for more info.\n\n## License\n\nThis bundle is under the [MIT license](LICENSE.md).\n\n[dompdf]: https://github.com/dompdf/dompdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnucleos%2Fnucleosdompdfbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnucleos%2Fnucleosdompdfbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnucleos%2Fnucleosdompdfbundle/lists"}