{"id":36998436,"url":"https://github.com/misterspelik/laravel-pdf","last_synced_at":"2026-01-13T23:59:39.390Z","repository":{"id":182783994,"uuid":"669098166","full_name":"misterspelik/laravel-pdf","owner":"misterspelik","description":"Mpdf wrapper for Laravel","archived":false,"fork":true,"pushed_at":"2025-01-08T12:32:28.000Z","size":152,"stargazers_count":52,"open_issues_count":4,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-21T20:57:47.699Z","etag":null,"topics":["laravel","mpdf","pdf","pdf-generation"],"latest_commit_sha":null,"homepage":"https://github.com/misterspelik/laravel-pdf/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"niklasravnsborg/laravel-pdf","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/misterspelik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-21T10:34:33.000Z","updated_at":"2025-10-10T02:36:49.000Z","dependencies_parsed_at":"2023-07-21T11:46:50.709Z","dependency_job_id":null,"html_url":"https://github.com/misterspelik/laravel-pdf","commit_stats":null,"previous_names":["misterspelik/laravel-pdf"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/misterspelik/laravel-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterspelik%2Flaravel-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterspelik%2Flaravel-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterspelik%2Flaravel-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterspelik%2Flaravel-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misterspelik","download_url":"https://codeload.github.com/misterspelik/laravel-pdf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterspelik%2Flaravel-pdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["laravel","mpdf","pdf","pdf-generation"],"created_at":"2026-01-13T23:59:38.684Z","updated_at":"2026-01-13T23:59:39.382Z","avatar_url":"https://github.com/misterspelik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Stable Version](https://poser.pugx.org/misterspelik/laravel-pdf/v/stable)](https://packagist.org/packages/misterspelik/laravel-pdf)\n[![Unstable Version](https://poser.pugx.org/misterspelik/laravel-pdf/v/unstable)](https://packagist.org/packages/misterspelik/laravel-pdf)\n[![License](https://poser.pugx.org/misterspelik/laravel-pdf/license)](https://packagist.org/packages/misterspelik/laravel-pdf)\n[![Total Downloads](https://poser.pugx.org/misterspelik/laravel-pdf/downloads)](https://packagist.org/packages/misterspelik/laravel-pdf)\n[![Monthly Downloads](https://poser.pugx.org/misterspelik/laravel-pdf/d/monthly)](https://packagist.org/packages/misterspelik/laravel-pdf)\n[![Daily Downloads](https://poser.pugx.org/misterspelik/laravel-pdf/d/daily)](https://packagist.org/packages/misterspelik/laravel-pdf)\n\n\n# Laravel PDF: mPDF wrapper for Laravel\n\n\u003e Easily generate PDF documents from HTML right inside of Laravel using this mPDF wrapper.\n\n## Supported versions\n\nMinimum supported version is Laravel 5\n\n## Installation\n\nRequire this package in your `composer.json` or install it by running:\n\n```\ncomposer require misterspelik/laravel-pdf\n```\n\n\u003e Note: This package supports auto-discovery features of Laravel 5.5+, You only need to manually add the service provider and alias if working on Laravel version lower then 5.5\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\tmisterspelik\\LaravelPdf\\Providers\\PdfServiceProvider::class\n]\n```\n\n```php\n'aliases' =\u003e [\n\t// ...\n\t'PDF' =\u003e misterspelik\\LaravelPdf\\Facades\\Pdf::class\n]\n```\n\nNow, you should publish package's config file to your config directory by using following command:\n\n```\nphp artisan vendor:publish\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\nuse PDF;\n\nfunction generate_pdf() {\n\t$data = [\n\t\t'foo' =\u003e 'bar'\n\t];\n\t$pdf = PDF::loadView('pdf.document', $data);\n\n\treturn $pdf-\u003estream('document.pdf');\n}\n```\n\n## Other methods\n\nIt is also possible to use the following methods on the `pdf` object:\n\n`output()`: Outputs the PDF as a string.  \n`save($filename)`: Save the PDF to a file  \n`download($filename)`: Make the PDF downloadable by the user.  \n`stream($filename)`: Return a response with the PDF to show in the browser.\n\n## Config\n\nIf you have published config file, you can change the default settings in `config/pdf.php` file:\n\n```php\nreturn [\n\t'format'           =\u003e 'A4', // See https://mpdf.github.io/paging/page-size-orientation.html\n\t'author'           =\u003e 'John Doe',\n\t'subject'          =\u003e 'This Document will explain the whole universe.',\n\t'keywords'         =\u003e 'PDF, Laravel, Package, Peace', // Separate values with comma\n\t'creator'          =\u003e 'Laravel Pdf',\n\t'display_mode'     =\u003e 'fullpage',\n];\n```\n\nTo override this configuration on a per-file basis use the fourth parameter of the initializing call like this:\n\n```php\nPDF::loadView('pdf', $data, [], [\n  'format' =\u003e 'A5-L'\n])-\u003esave($pdfFilePath);\n```\n\nYou can use a callback with the key 'instanceConfigurator' to access mpdf functions:\n```php\n$config = ['instanceConfigurator' =\u003e function($mpdf) {\n    $mpdf-\u003eSetImportUse();\n    $mpdf-\u003eSetDocTemplate(/path/example.pdf, true);\n}]\n \nPDF::loadView('pdf', $data, [], $config)-\u003esave($pdfFilePath);\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\tYour Header Content\n\u003c/htmlpageheader\u003e\n\n\u003chtmlpagefooter name=\"page-footer\"\u003e\n\tYour 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\theader: page-header;\n\tfooter: 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\n```php\nreturn [\n\t// ...\n\t'font_path' =\u003e base_path('resources/fonts/'),\n\t'font_data' =\u003e [\n\t\t'examplefont' =\u003e [\n\t\t\t'R'  =\u003e 'ExampleFont-Regular.ttf',    // regular font\n\t\t\t'B'  =\u003e 'ExampleFont-Bold.ttf',       // optional: bold font\n\t\t\t'I'  =\u003e 'ExampleFont-Italic.ttf',     // optional: italic font\n\t\t\t'BI' =\u003e 'ExampleFont-Bold-Italic.ttf' // optional: bold-italic font\n\t\t\t//'useOTL' =\u003e 0xFF,    // required for complicated langs like Persian, Arabic and Chinese\n\t\t\t//'useKashida' =\u003e 75,  // required for complicated langs like Persian, Arabic and Chinese\n\t\t]\n\t\t// ...add as many as you want.\n\t]\n\t// ...\n];\n```\n\n*Note*: If you are using `laravel-pdf` for producing PDF documents in a complicated language (like Persian, Arabic or Chinese) you should have `useOTL` and `useKashida` indexes in your custom font definition array. If you do not use these indexes, your characters will be shown dispatched and incorrectly in the produced PDF.\n\nNow you can use the font in CSS:\n\n```css\nbody {\n\tfont-family: 'examplefont', sans-serif;\n}\n```\n\n## Custom Styles\nYou can use your own styles in the generated PDFs. The css file have to be located in one folder, e.g. `/public/css/`. Add this to your configuration file (`/config/pdf.php`):\n\n```php\nreturn [\n\t//...\n    'defaultCssFile' =\u003e base_path('public/css/pdf.css'),\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 fews permissions: `'copy'`, `'print'`, `'modify'`, `'annot-forms'`, `'fill-forms'`, `'extract'`, `'assemble'`, `'print-highres'`.\n\n```php\nuse PDF;\n\nfunction generate_pdf()\n{\n\t$data = [\n\t\t'foo' =\u003e 'bar'\n\t];\n\t$pdf = PDF::loadView('pdf.document', $data);\n\t$pdf-\u003eSetProtection(['copy', 'print'], '', 'pass');\n\n\treturn $pdf-\u003estream('document.pdf');\n}\n```\n\nFind more information to `SetProtection()` here: https://mpdf.github.io/reference/mpdf-functions/setprotection.html\n\n## PDF Wrapper extension\n\nThis package has own wrapper for the Mpdf\\Mpdf class. But it can be also overrided or extended on the project level.\n\nThere is a setting in the config file to use a custom PdfWrapper.\n\n```php\nreturn [\n    // ...\n    'pdfWrapper' =\u003e 'misterspelik\\LaravelPdf\\Wrapper\\PdfWrapper',\n];\n```\n\nThe only requirement that the wrapper must implement the interface\n`misterspelik\\LaravelPdf\\PdfInterface\\PdfWrapperInterface`\n\n## Testing\n\nTo use the testing suite, you need some extensions and binaries for your local PHP. On macOS, you can install them like this:\n\n```\nbrew install imagemagick ghostscript\npecl install imagick\n```\n\n## License\n\nLaravel PDF is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterspelik%2Flaravel-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisterspelik%2Flaravel-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterspelik%2Flaravel-pdf/lists"}