{"id":13411031,"url":"https://github.com/robregonm/yii2-pdf","last_synced_at":"2025-07-25T03:32:38.185Z","repository":{"id":17069620,"uuid":"19834454","full_name":"robregonm/yii2-pdf","owner":"robregonm","description":"PDF Reports from HTML Views (Html to PDF formatter) for Yii 2.0","archived":false,"fork":false,"pushed_at":"2019-08-02T16:49:49.000Z","size":19,"stargazers_count":46,"open_issues_count":9,"forks_count":36,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-24T18:07:22.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robregonm.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}},"created_at":"2014-05-15T20:38:19.000Z","updated_at":"2022-10-27T08:26:50.000Z","dependencies_parsed_at":"2022-07-12T18:23:13.515Z","dependency_job_id":null,"html_url":"https://github.com/robregonm/yii2-pdf","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robregonm%2Fyii2-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robregonm%2Fyii2-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robregonm%2Fyii2-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robregonm%2Fyii2-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robregonm","download_url":"https://codeload.github.com/robregonm/yii2-pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227515477,"owners_count":17782647,"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":[],"created_at":"2024-07-30T20:01:10.942Z","updated_at":"2024-12-01T08:18:51.829Z","avatar_url":"https://github.com/robregonm.png","language":"PHP","funding_links":[],"categories":["Component 组件"],"sub_categories":[],"readme":"Yii2-PDF\n========\n\nPDF formatter for Yii2 using mPDF library.\n\nThis extension \"format\" HTML responses to PDF files (by default Yii2 includes HTML, JSON and XML formatters). Great for reports in PDF format using HTML views/layouts.\n\n##Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\n$ php composer.phar require robregonm/yii2-pdf \"*\"\n```\n\nor add\n\n```\n\"robregonm/yii2-pdf\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\n## Usage\n\nOnce the extension is installed, modify your application configuration to include:\n\n```php\nreturn [\n\t'components' =\u003e [\n\t\t...\n\t\t'response' =\u003e [\n\t\t\t'formatters' =\u003e [\n\t\t\t\t'pdf' =\u003e [\n\t\t\t\t\t'class' =\u003e 'robregonm\\pdf\\PdfResponseFormatter',\n\t\t\t\t\t'mode' =\u003e '', // Optional\n\t\t\t\t\t'format' =\u003e 'A4',  // Optional but recommended. http://mpdf1.com/manual/index.php?tid=184\n\t\t\t\t\t'defaultFontSize' =\u003e 0, // Optional\n\t\t\t\t\t'defaultFont' =\u003e '', // Optional\n\t\t\t\t\t'marginLeft' =\u003e 15, // Optional\n\t\t\t\t\t'marginRight' =\u003e 15, // Optional\n\t\t\t\t\t'marginTop' =\u003e 16, // Optional\n\t\t\t\t\t'marginBottom' =\u003e 16, // Optional\n\t\t\t\t\t'marginHeader' =\u003e 9, // Optional\n\t\t\t\t\t'marginFooter' =\u003e 9, // Optional\n\t\t\t\t\t'orientation' =\u003e 'Landscape', // optional. This value will be ignored if format is a string value.\n\t\t\t\t\t'options' =\u003e [\n\t\t\t\t\t\t// mPDF Variables\n\t\t\t\t\t\t// 'fontdata' =\u003e [\n\t\t\t\t\t\t\t// ... some fonts. http://mpdf1.com/manual/index.php?tid=454\n\t\t\t\t\t\t// ]\n\t\t\t\t\t]\n\t\t\t\t],\n\t\t\t]\n\t\t],\n\t\t...\n\t],\n];\n```\n\nIn the controller:\n\n```php\n\nclass MyController extends Controller {\n\tpublic function actionPdf(){\n\t\tYii::$app-\u003eresponse-\u003eformat = 'pdf';\n\t\t\n\t\t// Rotate the page\n\t\tYii::$container-\u003eset(Yii::$app-\u003eresponse-\u003eformatters['pdf']['class'], [\n\t\t\t'format' =\u003e [216, 356], // Legal page size in mm\n\t\t\t'orientation' =\u003e 'Landscape', // This value will be used when 'format' is an array only. Skipped when 'format' is empty or is a string\n\t\t\t'beforeRender' =\u003e function($mpdf, $data) {},\n\t\t\t]);\n\t\t\n\t\t$this-\u003elayout = '//print';\n\t\treturn $this-\u003erender('myview', []);\n\t}\n}\n\n```\n\n## License\n\nYii2-Pdf is released under the BSD-3 License. See the bundled `LICENSE.md` for details.\n\n\n# Useful URLs\n\n* [mPDF Manual](http://mpdf1.com/manual/index.php)\n\nEnjoy!\n\n[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=robregonm\u0026url=https://github.com/robregonm/yii2-pdf\u0026title=Yii2-PDF\u0026language=\u0026tags=github\u0026category=software) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobregonm%2Fyii2-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobregonm%2Fyii2-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobregonm%2Fyii2-pdf/lists"}