{"id":15045112,"url":"https://github.com/pontedilana/weasyprintbundle","last_synced_at":"2026-05-27T18:00:32.782Z","repository":{"id":43479318,"uuid":"386214544","full_name":"pontedilana/WeasyPrintBundle","owner":"pontedilana","description":"Easily create PDF in Symfony by converting HTML using WeasyPrint","archived":false,"fork":false,"pushed_at":"2025-12-12T09:26:38.000Z","size":85,"stargazers_count":40,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2026-05-03T22:06:38.461Z","etag":null,"topics":["bundle","hacktoberfest","pdf","pdf-generation","php","symfony","symfony-bundle","weasyprint"],"latest_commit_sha":null,"homepage":"","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/pontedilana.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["endelwar"],"ko_fi":"endelwar"}},"created_at":"2021-07-15T08:12:08.000Z","updated_at":"2026-01-30T16:24:53.000Z","dependencies_parsed_at":"2024-09-25T01:56:04.269Z","dependency_job_id":"a66b5b23-67f7-4151-a5dc-d768f45833d5","html_url":"https://github.com/pontedilana/WeasyPrintBundle","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":0.06382978723404253,"last_synced_commit":"2ec428d596538c65620ee07a3283b86e6b47f60f"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/pontedilana/WeasyPrintBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontedilana%2FWeasyPrintBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontedilana%2FWeasyPrintBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontedilana%2FWeasyPrintBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontedilana%2FWeasyPrintBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pontedilana","download_url":"https://codeload.github.com/pontedilana/WeasyPrintBundle/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontedilana%2FWeasyPrintBundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33577636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","hacktoberfest","pdf","pdf-generation","php","symfony","symfony-bundle","weasyprint"],"created_at":"2024-09-24T20:51:28.308Z","updated_at":"2026-05-27T18:00:32.777Z","avatar_url":"https://github.com/pontedilana.png","language":"PHP","funding_links":["https://github.com/sponsors/endelwar","https://ko-fi.com/endelwar"],"categories":[],"sub_categories":[],"readme":"# WeasyPrintBundle\n[PhpWeasyPrint](https://github.com/pontedilana/php-weasyprint) is a PHP (7.4+) wrapper for [WeasyPrint](https://weasyprint.org/) PDF generator.\nIt allows you to generate PDF files from HTML string or URL.\n\nThe WeasyPrintBundle provides a simple integration for your Symfony project.\n\nThis bundle is massively inspired by [KnpLabs/KnpSnappyBundle](https://github.com/KnpLabs/KnpSnappyBundle), of which it aims to be a one-to-one substitute\n\n## Installation\n\nWith [composer](https://getcomposer.org), require:\n\n`composer require pontedilana/weasyprint-bundle`\n\nThen enable it in your kernel (a flex recipe is coming soon):\n\n```php\n// config/bundles.php\n\u003c?php\n\nreturn [\n    //...\n    Pontedilana\\WeasyprintBundle\\WeasyprintBundle::class =\u003e ['all' =\u003e true],\n    //...\n];\n```\n\n## Configuration\nIf you need to change the binaries, change the instance options or even disable one or both services, you can do it through the configuration.\n\n```yaml\n# config/packages/weasyprint.yaml\nweasyprint:\n    pdf:\n        enabled:    true\n        binary:     /usr/local/bin/weasyprint\n        options:    []\n```\n\n\u003e **Note:** prefer an **absolute path** for `binary` (e.g. `/usr/local/bin/weasyprint`).\n\u003e Since php-weasyprint 2.5.1 the binary is verified with `is_executable()` before being\n\u003e run, and a bare command name like `weasyprint` is not resolved against the `PATH`.\n\u003e If you do leave a bare name, the bundle resolves it through the `PATH` for you (via\n\u003e Symfony's `ExecutableFinder`), but an absolute path is faster and unambiguous.\n\nIf you want to change temporary folder which is ```sys_get_temp_dir()``` by default, you can use\n\n```yaml\n# config/packages/weasyprint.yaml\nweasyprint:\n    temporary_folder: \"%kernel.cache_dir%/weasyprint\"\n```\n\nYou can also configure the timeout used by the generators with `process_timeout`:\n\n```yaml\n# config/packages/weasyprint.yaml\nweasyprint:\n    process_timeout: 20 # In seconds\n```\n\nSet it to `false` to disable the timeout entirely (useful when WeasyPrint runs inside a worker or queue that already manages timeouts):\n\n```yaml\n# config/packages/weasyprint.yaml\nweasyprint:\n    process_timeout: false\n```\n\nTo restrict the URL schemes allowed in options that accept URLs (a defense against SSRF and local file disclosure), use `allowed_schemes`. When omitted, php-weasyprint applies its own default (`['http', 'https']`). Requires php-weasyprint 2.6+.\n\n```yaml\n# config/packages/weasyprint.yaml\nweasyprint:\n    pdf:\n        allowed_schemes: ['http', 'https', 'file']\n```\n\n## Usage\n\nThe bundle registers one service:\n\n - the `weasyprint.pdf` service allows you to generate pdf files.\n\n### Generate a PDF document from a URL\n\n```php\n// @var Pontedilana\\PhpWeasyPrint\\Pdf\n$weasyprintPdf-\u003egenerate('https://www.github.com', '/path/to/the/file.pdf');\n```\n\n### Generate a PDF document from a twig view\n\n```php\n// @var Pontedilana\\PhpWeasyPrint\\Pdf\n$weasyprintPdf-\u003egenerateFromHtml(\n    $this-\u003erenderView(\n        'frontend/product/pdf.html.twig',\n        [\n            'some'  =\u003e $vars,\n        ]\n    ),\n    '/path/to/the/file.pdf'\n);\n```\n\n### Render a PDF document as a response from a controller\n\n```php\nuse Pontedilana\\WeasyprintBundle\\WeasyPrint\\Response\\PdfResponse;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\n\nclass SomeController extends AbstractController\n{\n    public function pdf(Pontedilana\\PhpWeasyPrint\\Pdf $weasyprintPdf)\n    {\n        $html = $this-\u003erenderView(\n            'frontend/product/pdf.html.twig',\n            [\n                'some'  =\u003e $vars,\n            ]\n        );\n\n        return new PdfResponse(\n            $weasyprintPdf-\u003egetOutputFromHtml($html),\n            'file.pdf'\n        );\n    }\n}\n```\n\n**Note:** Filenames with accented characters (e.g., `invoice_àèìòù.pdf`) are automatically supported. The bundle generates an ASCII-safe fallback for older browsers while preserving the original UTF-8 filename for modern browsers (following [RFC 6266](https://www.rfc-editor.org/rfc/rfc6266.html)).\n\n### Render a PDF document with a relative url inside like CSS files or images\n\n```php\nuse Pontedilana\\WeasyprintBundle\\WeasyPrint\\Response\\PdfResponse;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\n\nclass SomeController extends AbstractController\n{\n    public function pdf(Pontedilana\\PhpWeasyPrint\\Pdf $weasyprintPdf)\n    {\n        $pageUrl = $this-\u003egenerateUrl('homepage', [], true); // use absolute path!\n\n        return new PdfResponse(\n            $weasyprintPdf-\u003egetOutput($pageUrl),\n            'file.pdf'\n        );\n    }\n}\n```\n\n## Credits\n\nWeasyPrintBundle and [PhpWeasyPrint](https://github.com/pontedilana/php-weasyprint) have been developed by [Pontedilana](https://www.pontedilana.it/).  \nSnappyBundle has been developed by [KnpLabs](https://knplabs.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpontedilana%2Fweasyprintbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpontedilana%2Fweasyprintbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpontedilana%2Fweasyprintbundle/lists"}