{"id":21541768,"url":"https://github.com/zanysoft/laravel-pdf","last_synced_at":"2025-09-14T14:32:47.055Z","repository":{"id":57089313,"uuid":"82532013","full_name":"zanysoft/laravel-pdf","owner":"zanysoft","description":"PDF document generator from HTML","archived":false,"fork":false,"pushed_at":"2024-12-18T16:27:43.000Z","size":32,"stargazers_count":7,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T06:47:23.831Z","etag":null,"topics":["html-to-pdf","html-to-pdf-php","laravel","laravel-pdf","mpdf","pdf","pdf-converter","pdf-document","pdf-files","pdf-generation","php"],"latest_commit_sha":null,"homepage":"https://zanysoft.github.io/laravel-pdf/","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/zanysoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2017-02-20T08:00:19.000Z","updated_at":"2025-03-13T15:50:45.000Z","dependencies_parsed_at":"2025-04-10T04:32:16.775Z","dependency_job_id":"9e75a1e0-6b2d-462c-826a-219a7be81801","html_url":"https://github.com/zanysoft/laravel-pdf","commit_stats":{"total_commits":19,"total_committers":5,"mean_commits":3.8,"dds":0.5789473684210527,"last_synced_commit":"9d1a2bbb345007cfe82f6ff05c93d1070679e109"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zanysoft/laravel-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zanysoft","download_url":"https://codeload.github.com/zanysoft/laravel-pdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-pdf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265538590,"owners_count":23784617,"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":["html-to-pdf","html-to-pdf-php","laravel","laravel-pdf","mpdf","pdf","pdf-converter","pdf-document","pdf-files","pdf-generation","php"],"created_at":"2024-11-24T05:07:34.476Z","updated_at":"2025-07-16T20:35:21.739Z","avatar_url":"https://github.com/zanysoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel PDF: PDF generator for Laravel\n\n\u003e Easily generate PDF documents from HTML right inside of Laravel using this PDF wrapper.\n\n## Contents\n- [Installation Guide](#installation-guide)\n- [Configuration](#configuration)\n- [Basic Usage](#basic-usage)\n- [Headers and Footers](#headers-and-footers)\n- [Included Fonts](#included-fonts)\n- [Custom Fonts](#custom-fonts)\n- [Set Protection](#set-protection)\n- [Documentation](#documentation)\n\n\n### Installation Guide\n\nRequire this package in your `composer.json` or install it by running:\n\n```\ncomposer require zanysoft/laravel-pdf\n```\n\nTo start using Laravel, add the Service Provider and the Facade to your `config/app.php`:\n\n```php\n'providers' =\u003e [\n\t// ...\n\tZanySoft\\LaravelPDF\\PdfServiceProvider::class\n]\n```\n\n```php\n'aliases' =\u003e [\n\t// ...\n\t'PDF' =\u003e ZanySoft\\LaravelPDF\\Facades\\PDF::class\n]\n```\n\n### Configuration\nThe defaults configuration settings are set in `config/pdf.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:\n\n    php artisan vendor:publish --provider=\"ZanySoft\\LaravelPDF\\PdfServiceProvider\"\n\n\n### Basic Usage\n\nTo use Laravel PDF add something like this to one of your controllers. You can pass data to a view in `/resources/views`.\n\n```php\n    use ZanySoft\\LaravelPDF\\Facades\\PDF;\n    \n    $data = ['foo' =\u003e 'bar'];\n    $pdf = PDF::make('document.pdf');\n    $pdf-\u003eloadView('pdf.document', $data);\n    \n    return $pdf-\u003estream();\n```\nor\n\n```php\n    use ZanySoft\\LaravelPDF\\PDF;\n\n    $pdf = new PDF();\n    $pdf-\u003eloadView('pdf.document', $data);\n    \n    return $pdf-\u003estream('document.pdf');\n\n```\n\nIf you want to generate from html content:\n```php\n    $content = \"Hello this is first pdf file.\"\n    $pdf-\u003eloadHTML($content);\n    \n    return $pdf-\u003estream('document.pdf');\n```\n\nIf you want to generate from files:\n```php\n    $file = \"file.txt\"\n    $pdf-\u003eloadFile($file);\n    \n    return $pdf-\u003estream('document.pdf');\n```\n\nIf you want download pdf file:\n```php\n    return $pdf-\u003eembed('document.pdf');\n```\n\nIf you want to save pdf to server:\n```php\n    return $pdf-\u003esave('with-complete-path/document.pdf');\n```\n\nIf you want add pdf file as attachment to email:\n```php\n    return $pdf-\u003eembed('document.pdf');\n```\n\n### Headers and Footers\n\nIf you want to have headers and footers that appear on every page, add them to your `\u003cbody\u003e` tag like this:\n\n```html\n\u003chtmlpageheader name=\"page-header\"\u003e\n    Your Header Content\n\u003c/htmlpageheader\u003e\n\n\u003chtmlpagefooter name=\"page-footer\"\u003e\n    Your Footer Content\n\u003c/htmlpagefooter\u003e\n```\n\nNow you just need to define them with the name attribute in your CSS:\n\n```css\n@page {\n    header: page-header;\n    footer: page-footer;\n}\n```\n\nInside of headers and footers `{PAGENO}` can be used to display the page number.\n\n### Included Fonts\n\nBy default you can use all the fonts [shipped with mPDF](https://mpdf.github.io/fonts-languages/available-fonts-v6.html).\n\n### Custom Fonts\n\nYou can use your own fonts in the generated PDFs. The TTF files have to be located in one folder, e.g. `/resources/fonts/`. Add this to your configuration file (`/config/pdf.php`):\n```php\n    return [\n        'custom_font_path' =\u003e base_path('/resources/fonts/'), // don't forget the trailing slash!\n    ];\n```\nAnd then:\n```php\n    $fontdata = array(\n        'examplefont' =\u003e [\n            'R' =\u003e 'ExampleFont-Regular.ttf',      // regular font\n            'B' =\u003e 'ExampleFont-Bold.ttf',         // optional: bold font\n            'I' =\u003e 'ExampleFont-Italic.ttf',       // optional: italic font\n            'BI' =\u003e 'ExampleFont-Bold-Italic.ttf', // optional: bold-italic font\n        ]\n        // ...add as many as you want.\n    );\n\n    $pdf-\u003eaddCustomFont($fontdata, true);\n    // If your font file is unicode and \"OpenType Layout\" then set true. Default value is false.\n```\n\nNow you can use the font in CSS:\n\n```css\nbody {\n    font-family: 'examplefont', sans-serif;\n}\n```\n\n### Set Protection\n\nTo set protection, you just call the `SetProtection()` method and pass an array with permissions, an user password and an owner password.\n\nThe passwords are optional.\n\nThere are a few permissions: `'copy'`, `'print'`, `'modify'`, `'annot-forms'`, `'fill-forms'`, `'extract'`, `'assemble'`, `'print-highres'`.\n\n```php\nuse PDF;\n\nfunction generate_pdf() {\n    $data = [\n        'foo' =\u003e 'bar'\n    ];\n    $pdf = PDF::make();\n    $pdf-\u003eSetProtection(['copy', 'print'], 'user_pass', 'owner_pass')\n    $pdf-\u003eloadView('pdf.document', $data);\n    \n    return $pdf-\u003estream('document.pdf');\n}\n```\n\nFind more information to `SetProtection()` here: https://mpdf.github.io/reference/mpdf-functions/setprotection.html\n\n### Documentation\n\n Visit this link for more options and settings: https://mpdf.github.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanysoft%2Flaravel-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzanysoft%2Flaravel-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanysoft%2Flaravel-pdf/lists"}