{"id":20961801,"url":"https://github.com/heimrichhannot/pdf-creator","last_synced_at":"2026-02-13T15:08:29.070Z","repository":{"id":49847521,"uuid":"339107574","full_name":"heimrichhannot/pdf-creator","owner":"heimrichhannot","description":"PdfCreator is a high level API for PDF file creating with PHP.","archived":false,"fork":false,"pushed_at":"2024-08-01T12:29:43.000Z","size":177,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-12-14T16:04:29.506Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heimrichhannot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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}},"created_at":"2021-02-15T14:43:15.000Z","updated_at":"2024-08-01T12:29:43.000Z","dependencies_parsed_at":"2025-04-05T21:34:52.648Z","dependency_job_id":null,"html_url":"https://github.com/heimrichhannot/pdf-creator","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/heimrichhannot/pdf-creator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fpdf-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fpdf-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fpdf-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fpdf-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heimrichhannot","download_url":"https://codeload.github.com/heimrichhannot/pdf-creator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fpdf-creator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29411138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"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":[],"created_at":"2024-11-19T02:17:34.640Z","updated_at":"2026-02-13T15:08:29.050Z","avatar_url":"https://github.com/heimrichhannot.png","language":"PHP","readme":"# PDF Creator\n\nPdfCreator is a high level API for PDF file creating with PHP. Its goal is to make usage of existing libraries easier and object-orientated.\n\n## Features\n\n- supported libraries:\n  - [Dompdf](https://github.com/dompdf/dompdf)\n  - [mPDF](https://github.com/mpdf/mpdf)\n  - [TCPDF](https://github.com/tecnickcom/TCPDF)\n\n## Example\n\n```php\nuse HeimrichHannot\\PdfCreator\\Concrete\\MpdfCreator;\nuse HeimrichHannot\\PdfCreator\\PdfCreatorFactory;\n\n$pdf = PdfCreatorFactory::createInstance(MpdfCreator::getType());\n$pdf-\u003esetHtmlContent($this-\u003ecompile())\n    -\u003esetFilename($this-\u003egetFileName())\n    -\u003esetFormat('A4')\n    -\u003esetOrientation($pdf::ORIENTATION_PORTRAIT)\n    -\u003eaddFont(\n        \"/path_to_project/assets/fonts/my_great_font.tff\", \n        \"myGreatFont\", \n        $pdf::FONT_STYLE_REGUALAR,\n        \"normal\"\n    )\n    -\u003esetMargins(15, 10, 15,10)\n    -\u003esetTemplateFilePath(\"/path_to_project/assets/pdf/mastertemplate.pdf\")\n    -\u003esetOutputMode($pdf::OUTPUT_MODE_DOWNLOAD)\n    -\u003erender()\n;\n```\n\n## Usage\n\n### Install\n\nWe recommend installing this library with composer:\n\n    composer require heimrichhannot/pdf-creator\n\nYou also need to install the pdf library, you want to use this bundle with:\n- Dompdf (version 1 to 3 are supported):\n  - `\"dompdf/dompdf\": \"^3.0\"`\n  - if you want to use master templates in Dompdf, you also need FPDI and TCPDF:    \n    - `\"tecnickcom/tcpdf\": \"^6.3\"`\n    - `\"setasign/fpdi\": \"^2.3\"`\n- mPDF (version 7 and 8 are supported):\n  - `\"mpdf/mpdf\": \"^8.0\"`\n- TCPDF\n  - `\"tecnickcom/tcpdf\": \"^6.3\"`\n  - if you want to use master templates in TCPDF, you also need FPDI:    \n    - `\"setasign/fpdi\": \"^2.3\"`\n\nIf you're using [Contao](https://contao.org/), you could try the [PDF Creator Bundle](https://github.com/heimrichhannot/contao-pdf-creator-bundle), which is based on this library.\n\n\n### Use callback for custom adjustments\n\nDue the high level approach not all specific library functionality could be supported. To add specific configuration, you can use the callback mechanism comes with this api.\n\nCallback | Description\n-------- | -----------\nBeforeCreateLibraryInstanceCallback | Is evaluated before the library instance is created and allows to modifiy the constructor parameters.\nBeforeOutputPdfCallback | Is evaluated before the library method to output the pdf is called and provide the library instance and the output method parameters.\n\n```php\nuse HeimrichHannot\\PdfCreator\\BeforeCreateLibraryInstanceCallback;\nuse HeimrichHannot\\PdfCreator\\BeforeOutputPdfCallback;\nuse HeimrichHannot\\PdfCreator\\Concrete\\MpdfCreator;\nuse HeimrichHannot\\PdfCreator\\PdfCreatorFactory;\n\n$pdf = PdfCreatorFactory::createInstance(MpdfCreator::getType());\n\n$pdf-\u003esetBeforeCreateInstanceCallback(function (BeforeCreateLibraryInstanceCallback $callbackData) {\n    $parameter = $callbackData-\u003egetConstructorParameters();\n    $parameter['config']['fonttrans'] = [\n        'rotis-sans-serif-w01-bold' =\u003e 'rotis-sans-serif',\n        'rotissansserifw01-bold' =\u003e 'rotis-sans-serif',\n    ];\n    $callbackData-\u003esetConstructorParameters($parameter);\n    return $callbackData;\n});\n\n$pdf-\u003esetBeforeOutputPdfCallback(function (BeforeOutputPdfCallback $callbackData) use ($pdf) {\n    $mpdf = $callbackData-\u003egetLibraryInstance();\n    $mpdf-\u003eAddPage();\n    $parameters = $callbackData-\u003egetOutputParameters();\n    $parameters['name'] = 'custom_'.$pdf-\u003egetFilename();\n    $callbackData-\u003esetOutputParameters($parameters);\n});\n```\n\n### Use return value\n\nThe render method return an `PdfCreatorResult` instance. It contains the output \nmode and filepath or filecontent for corresponding output modes.\n\n```php\nuse HeimrichHannot\\PdfCreator\\Concrete\\DompdfCreator;\nuse HeimrichHannot\\PdfCreator\\PdfCreatorFactory;\n\n$pdf = PdfCreatorFactory::createInstance(DompdfCreator::getType());\n$result = $pdf-\u003esetOutputMode($pdf::OUTPUT_MODE_FILE)\n    // ...\n    -\u003erender()\n;\n$filepath = $result-\u003egetFilePath();\n\n$pdf = PdfCreatorFactory::createInstance(DompdfCreator::getType());\n$result = $pdf-\u003esetOutputMode($pdf::OUTPUT_MODE_STRING)\n    // ...\n    -\u003erender()\n;\n$filepath = $result-\u003egetFileContent();\n```\n\n## Documentation\n\n- [API Documentation](https://heimrichhannot.github.io/pdf-creator/)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fpdf-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheimrichhannot%2Fpdf-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fpdf-creator/lists"}