{"id":15023014,"url":"https://github.com/its404/php-puppeteer","last_synced_at":"2026-03-06T04:31:21.330Z","repository":{"id":41432360,"uuid":"116368226","full_name":"its404/php-puppeteer","owner":"its404","description":"PHP Wrapper of Google Chrome Puppeteer for PDF Generation","archived":false,"fork":false,"pushed_at":"2020-10-09T07:32:20.000Z","size":197,"stargazers_count":30,"open_issues_count":0,"forks_count":9,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-20T22:59:03.188Z","etag":null,"topics":["pdf","php5","puppeteer"],"latest_commit_sha":null,"homepage":"","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/its404.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":"2018-01-05T09:37:10.000Z","updated_at":"2024-07-01T11:23:43.000Z","dependencies_parsed_at":"2022-08-21T13:50:37.412Z","dependency_job_id":null,"html_url":"https://github.com/its404/php-puppeteer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/its404/php-puppeteer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its404%2Fphp-puppeteer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its404%2Fphp-puppeteer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its404%2Fphp-puppeteer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its404%2Fphp-puppeteer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/its404","download_url":"https://codeload.github.com/its404/php-puppeteer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its404%2Fphp-puppeteer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30161729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:22:03.816Z","status":"ssl_error","status_checked_at":"2026-03-06T04:22:00.183Z","response_time":250,"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":["pdf","php5","puppeteer"],"created_at":"2024-09-24T19:58:38.391Z","updated_at":"2026-03-06T04:31:21.312Z","avatar_url":"https://github.com/its404.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP Puppeteer\n===========\nThis project provides the ability to generate PDF with [Puppeteer](https://github.com/GoogleChrome/puppeteer) in PHP\n\n- PHP 5 Compatible\n- No Dependent Package\n- Easy to Use\n\n# Dependencies\nThe library is running based on [Nodejs](https://nodejs.org/en/)(7.6 above) and [Puppeteer](https://github.com/GoogleChrome/puppeteer)\nIt is tested under NodeJS 8.\n\nInstallation on CentOS 7:\n\n```\nsudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -\nsudo yum install -y nodejs pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc\nsudo npm install --global --unsafe-perm puppeteer\nsudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium\n```\n\nInstallation on Ubuntu 16.04:\n\n```\ncurl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -\nsudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget\nsudo npm install --global --unsafe-perm puppeteer\nsudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium\n```\n\n# Installation\nInstall `its404/php-puppeteer` using Composer.\n~~~\ncomposer require its404/php-puppeteer\n~~~\n# Usage\n## Parameters\nThe library has set some default parameter values to support basic features, you can set the customized parameters to override the default ones, it supports all parameters of [Puppeteer API](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md)\n\n__Sample parameter array:__\n\n~~~\n$config  = [\n    'html' =\u003e \"\u003ch1\u003eHello World\u003c/h1\u003e\",\n\t'pdf' =\u003e [\n\t\t'path' =\u003e '/tmp/test.pdf',\n\t\t'margin' =\u003e [\n\t\t\t'top' =\u003e '10mm',\n\t\t\t'right' =\u003e '10mm',\n\t\t\t'bottom' =\u003e '10mm',\n\t\t\t'left' =\u003e '10mm',\n\t\t]\n\t]\n];\n~~~\n\n\u003e **Note:**\n\u003e 1. If both `$config['pdf']['html']` and $config['pdf']['url'] are set, `html` will be picked up. \n\u003e 2. If `$config['pdf']['path']` is not set, will return pdf data\n\n## Import\nYou need to import this namespace at the top of your PHP class\n\n~~~\nuse Its404\\PhpPuppeteer\\Browser;\n~~~\n\n\n__PDF by URL__\n\nYou can generate PDF by URL through `pdf` function:\n\n~~~\npublic function actionTest1()\n{\n\t$config = [\n\t\t\"url\" =\u003e \"https://www.highcharts.com/demo/line-basic\",\n\t];\n\t$browser = new Browser();\n\t$browser-\u003eisDebug = true;\n\t$content = $browser-\u003epdf($config);\n\t\n\theader(\"Content-type:application/pdf\");\n\techo $content;\n}\n~~~\n\nYou can set any parameter in `$config` to override the default values\n\n__PDF by HTML__\n\nYou can generate PDF by html code through `pdf` function:\n\n~~~\npublic function actionTest2()\n{\n\t$config = [\n\t\t\"html\" =\u003e \"\u003ch1\u003eHello Wolrd\u003c/h1\u003e\"\n\t];\n\t$browser = new Browser();\n\t$content = $browser-\u003epdf($config);\n\t\n\theader(\"Content-type:application/pdf\");\n\techo $content;\n}\n~~~\n\u003e **Debug** The class `Browser` has one parameter `$isDebug`, it would be debug mode if it's `true`, detailed error messages would be returned from `pdf` function if an error happened during Puppeteer running.\n\n__PDF to specific path__\n\nYou can generate PDF to a specific path by setting `$config['pdf']['path']`\n\n~~~\npublic function actionTest3()\n{\n\t$config = [\n\t\t\"html\" =\u003e \"\u003ch1\u003eHello Wolrd\u003c/h1\u003e\",\n\t\t'pdf' =\u003e [\n\t\t\t'path' =\u003e '/tmp/test.pdf',\n\t\t]\n\t];\n\t$browser = new Browser();\n\t$browser-\u003eisDebug = true;\n\t$result = $browser-\u003epdf($params);\n\t\n\tif (isset($result['returnVal'])\u0026\u0026 $result['returnVal'] == 0) {\n\t\techo \"PDF generated successfully\";\n\t} else {\n\t\techo \"Failed to generate PDF\";\n\t\tvar_dump($result['output']);\n\t}\n}\n~~~\n\n__Start a new page on PDF__\n\nYou can add following html code in the html where you'd like to start a new page for PDF.\n\n~~~\n\u003cdiv style=\"page-break-after:always;\"\u003e\u003c/div\u003e\n~~~\n\n# More Examples?\n\nYou can find more examples from [here](https://github.com/its404/php-puppeteer/tree/master/examples)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits404%2Fphp-puppeteer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fits404%2Fphp-puppeteer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits404%2Fphp-puppeteer/lists"}