{"id":25440233,"url":"https://github.com/tarfin-labs/easy-pdf","last_synced_at":"2026-04-08T16:00:33.322Z","repository":{"id":39633236,"uuid":"244641216","full_name":"tarfin-labs/easy-pdf","owner":"tarfin-labs","description":"Pdf wrapper for laravel","archived":false,"fork":false,"pushed_at":"2025-02-24T13:48:04.000Z","size":209,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-03-16T04:45:48.221Z","etag":null,"topics":["laravel","pdf","pdf-merge","pdf-parser","php","tcpdf"],"latest_commit_sha":null,"homepage":null,"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/tarfin-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2020-03-03T13:20:08.000Z","updated_at":"2025-07-07T12:45:34.000Z","dependencies_parsed_at":"2025-02-24T14:33:25.847Z","dependency_job_id":"276f710b-e0b9-4f0d-90d6-d57be0b74501","html_url":"https://github.com/tarfin-labs/easy-pdf","commit_stats":{"total_commits":86,"total_committers":8,"mean_commits":10.75,"dds":0.7325581395348837,"last_synced_commit":"a7efe880a508ec65ac3148c939c65f6505261bde"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/tarfin-labs/easy-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Feasy-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Feasy-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Feasy-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Feasy-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarfin-labs","download_url":"https://codeload.github.com/tarfin-labs/easy-pdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Feasy-pdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"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","pdf","pdf-merge","pdf-parser","php","tcpdf"],"created_at":"2025-02-17T11:29:59.651Z","updated_at":"2026-04-08T16:00:33.316Z","avatar_url":"https://github.com/tarfin-labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# easy-pdf\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tarfin-labs/easy-pdf.svg?style=flat-square)](https://packagist.org/packages/tarfin-labs/easy-pdf)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/tarfin-labs/easy-pdf/tests?label=tests)\n[![Quality Score](https://img.shields.io/scrutinizer/g/tarfin-labs/easy-pdf.svg?style=flat-square)](https://scrutinizer-ci.com/g/tarfin-labs/easy-pdf)\n[![Total Downloads](https://img.shields.io/packagist/dt/tarfin-labs/easy-pdf.svg?style=flat-square)](https://packagist.org/packages/tarfin-labs/easy-pdf)\n\n## Introduction\neasy-pdf is a [tcpdf](https://tcpdf.org/) wrapper for Laravel 13.x. Requires PHP 8.3 or higher.\n\n\u003e For Laravel 6.x–12.x support, use the [2.x branch](https://github.com/tarfin-labs/easy-pdf/tree/2.x).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require tarfin-labs/easy-pdf\n```\n\n## Usage\n\n### Creating pdf with html.\n\nYou can create a pdf with html. Easy-pdf also provides easy configuration with tcpdf pdf settings and informations. \n\n``` php\n$pdf = EasyPdf::withInformation([\n    'Creator'   =\u003e 'Tarfin',\n    'Author'    =\u003e 'Faruk Can',\n    'Title'     =\u003e 'EasyPdf',\n    'Keywords'  =\u003e 'easy, pdf',\n    'AutoPageBreak' =\u003e [true, 0],\n])\n    -\u003ewithConfig([\n        'ImageScale' =\u003e PDF_IMAGE_SCALE_RATIO,\n])\n    -\u003esetFont('times', 16) // use default fonts\n    -\u003eloadHtml($html) // each load html creates a new page\n    -\u003econtent(); // return pdf content as a string\n```\n\nThis will return pdf content as a string. If you want save pdf, use save method:\n\n``` php\n// This will save pdf to given path.\n$pdf-\u003esave($filePath);\n```\n\nAlso you can stream pdf directly to the browser using stream method:\n``` php\n// This will stream pdf to the directly browser.\n$pdf-\u003estream();\n```\n\nYou can add custom TTF font using addFont or use default fonts:\n``` php\n// Add custom font using font path\n$pdf-\u003eaddFont($fontPath, $fontSize);\n\n// Use default fonts with supported font name\n$pdf-\u003esetFont('helvetica', 16);\n```\n\nIf you want the use default fonts, here is the list:\n`courier`, `courierB`, `courierBI`, `courierI`, `helvetica`, `helveticaB`, `helveticaBI`, `helveticaI`, `symbol`, `times`, `timesB`, `timesBI`, `timesI`, `zapfdingbats`\n\nEasy pdf provides barcode and qrcode support.\n\n``` php\n// This will add barcode to the pdf with given dimensions.\n$code = '[111011101110111][010010001000010][010011001110010][010010000010010][010011101110010]';\n$pdf-\u003eaddBarcode($code, 80, 60, 30, 20); // x-y coordinates and width-height\n\n// // This will add qrcode with best error correction to the pdf with given dimensions.\n$pdf-\u003eaddQrcode('tarfin', 80, 60, 30, 20); // x-y coordinates and width-height\n```\n\nYou can add image to the pdf with dimensions.\n``` php\n// This will add image to the pdf with given dimensions.\n$pdf-\u003eaddImage($imagePath, 80, 60, 30, 20); // x-y coordinates and width-height\n```\n\nYou can set active page using `setPage()` method.\n```php\n// This will set the active page as 1.\n$pdf-\u003esetPage(1);\n```\n\nYou can set margins using `setMargins()` method.\n```php\n// This will set margin as 10 for left, 15 for top, 20 for right\n// and overwrite the default margins.  \n$pdf-\u003esetMargins(10, 15, 20, true);\n```\n\nYou can add image to page header using `setHeaderData()` method.\n```php\n// $textColor and $lineColor must be RGB as array format. '[255, 255, 255]'\n$pdf-\u003esetHeaderData($image, $width, $textColor, $lineColor);\n```\n\nYou can set header margin using `setHeaderMargin()` method.\n```php\n// This will set the minimum distance between header and top page margin. \n$pdf-\u003esetHeaderMargin(10);\n```\n\nYou can set test and line colors of footer using `setFooterData()` method.\n```php\n// The first parameter is text color and the last one is line color.\n$pdf-\u003esetFooterData([0, 64, 255], [0, 64, 128]);\n```\n\nYou can set footer margin using `setFooterMargin()` method.\n```php\n// This will set the minimum distance between footer and bottom page margin. \n$pdf-\u003esetFooterMargin(10);\n```\n\nYou can set footer font using `setFooterFontSize()` method.\n```php\n// This will set the footer font size to 10.\n$pdf-\u003esetFooterFontSize(10);\n```\nYou can set paper handling option to use when printing the file from the print dialog.\n```php\n// This will set the print to single sided. \n$pdf-\u003esetDuplex('Simplex'); \n\n// This will set duplex and flip on the short edge of the sheet\n$pdf-\u003esetDuplex('DuplexFlipShortEdge'); \n\n// This will set duplex and flip on the long edge of the sheet\n$pdf-\u003esetDuplex('DuplexFlipLongEdge'); \n```\n\nYou can add \n\n### Parsing pdf\n\nYou can parse the pdf and get the page you want.\n``` php\n// This will return pdf page count.\n// $file can be path, url or blob.\n$fileCount = EasyPdf::parser($file)-\u003ecount();\n\n// You can use stream or content method here as well.\n$parsedPdf = EasyPdf::parser($file)\n    -\u003esetPage(1)\n    -\u003esave(storage_path('app/imports/new.pdf'));\n```\n\n### Merging pdf\n\nYou can merge multiple pdf into the one with easily using easy-pdf.\n``` php\n// Pdf paths.\n// Pdf paths can be path, url or blob.\n$files = [\n    '/path/to/the/file.pdf',\n    '/path/to/the/anotherFile.pdf',\n];\n\n// You can use stream or content method here as well.\n$pdf = EasyPdf::merge($files)\n            -\u003econtent();\n```\n\n### Splitting pdf\n\nYou can split pdf file into multiple pdf files easily using easy-pdf.\n``` php\n// Pdf path.\n// Pdf path can be path, url or blob.\n\n$file = '/path/to/the/file.pdf';\n\n// You can use splitTo method to get new pdf contents\n// chunkSize argument determines that how many page should contain every pdf file\n// For example if you want to split your pdf file as each file includes 10 page\n// Then you must set chunkSize argument to 10\n$pdfs = EasyPdf::parser($file)\n            -\u003esplitTo(10);\n\nforeach($pdfs as $pdfContent) {\n    // Your code here\n}\n```\n\n### Resetting the instance\nIf you try to generate pdf inside a Laravel queue, sometimes there might occure an error like `undefined property: TCPDF::$h`.\n\nThe error occurs 2nd time you use the EasyPdf facade after you already created a PDF. Since EasPdf service is registered as singleton to the service container, it returns the same instance when you use it 2nd time and somehow it's broken.\n\nTo avoid the error which mentioned above you can use `reset()` method in the beginning. This will return a new TCPDF instance.\n\n```php\n$pdf = EasyPdf::reset()\n    -\u003ewithInformation([\n        'Creator'   =\u003e 'Tarfin',\n        'Author'    =\u003e 'Faruk Can',\n        'Title'     =\u003e 'EasyPdf',\n        'Keywords'  =\u003e 'easy, pdf',\n        'AutoPageBreak' =\u003e [true, 0],\n    ])\n    -\u003ewithConfig([\n            'ImageScale' =\u003e PDF_IMAGE_SCALE_RATIO,\n    ])\n    -\u003esetFont('times', 16) // use default fonts\n    -\u003eloadHtml($html) // each load html creates a new page\n    -\u003econtent(); // return pdf content as a string\n```\n\n### Pdf Header and Setter\nAfter using `reset()` method for creating new Tcpdf instance for each page, automatically header line added to Pdf. Whether you want or not you can use `setHeader' for print header or `setFooter` for print footer content.\n\n```php\n$pdf = EasyPdf::reset()\n    -\u003esetHeader(false);\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update the tests as appropriate.\n\n### Security\n\nIf you discover any security-related issues, please email development@tarfin.com instead of using the issue tracker.\n\n## Credits\n\n- [Faruk Can](https://github.com/frkcn)\n- [Yunus Emre Deligöz](https://github.com/deligoez)\n- [Hakan Özdemir](https://github.com/hozdemir)\n- [Turan Karatuğ](https://github.com/tkaratug)\n- [All Contributors](../../contributors)\n\n### License\neasy-pdf is open-sourced software licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarfin-labs%2Feasy-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarfin-labs%2Feasy-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarfin-labs%2Feasy-pdf/lists"}