{"id":16243581,"url":"https://github.com/flyte/chromium-pdf-api","last_synced_at":"2026-01-21T14:02:37.405Z","repository":{"id":37231123,"uuid":"187718870","full_name":"flyte/chromium-pdf-api","owner":"flyte","description":"A server which uses headless Chromium to visit any URL and create a PDF from it. Uses a simple JSON API to set the URL and options for PDF creation.","archived":false,"fork":false,"pushed_at":"2022-08-23T17:48:22.000Z","size":259,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-07T20:33:29.281Z","etag":null,"topics":["cdp","chrome","chromium","json-api","pdf","pdf-converter","pdf-generation","python","python3"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/flyte/chromium-pdf-api","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flyte.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}},"created_at":"2019-05-20T21:57:20.000Z","updated_at":"2023-01-31T16:25:30.000Z","dependencies_parsed_at":"2022-06-21T22:53:31.794Z","dependency_job_id":null,"html_url":"https://github.com/flyte/chromium-pdf-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flyte/chromium-pdf-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fchromium-pdf-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fchromium-pdf-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fchromium-pdf-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fchromium-pdf-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyte","download_url":"https://codeload.github.com/flyte/chromium-pdf-api/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyte%2Fchromium-pdf-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28634786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"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":["cdp","chrome","chromium","json-api","pdf","pdf-converter","pdf-generation","python","python3"],"created_at":"2024-10-10T14:15:29.077Z","updated_at":"2026-01-21T14:02:37.389Z","avatar_url":"https://github.com/flyte.png","language":"Python","readme":"Chromium PDF API\n================\n\nA server which uses headless Chromium to visit any URL and create a PDF from it. Uses a simple JSON API to set the URL and options for PDF creation.\n\nUsage\n-----\n\nRun the container:\n\n```\ndocker run -ti --rm -p 8080:8080 flyte/chromium-pdf-api\n```\n\nMake a request:\n\n```\ncurl -X POST \\\n    --header \"Content-Type: application/json\" \\\n    --data '{\"url\": \"https://www.google.com\"}' \\\n    localhost:8080\n```\n\nExample request:\n\n```json\n{\n    \"url\": \"https://www.google.com\"\n}\n```\n\nExample response:\n\n```json\n{\n    \"url\": \"https://www.google.com\",\n    \"pdf\": \"\u003cbase64 string of PDF\u003e\",\n}\n```\n\n## API\n\nEverything except for the `url` parameter is optional.\n\n```json\n{\n    \"url\": \"\u003curl of page to turn into PDF\u003e\",\n    \"max_size\": \"\u003cmaximum size (in bytes) of the PDF - will error if exceeded\u003e\",\n    \"timeout\": \"\u003cmaximum seconds to wait overall\u003e\",\n    \"load_timeout\": \"\u003cmaximum seconds to wait for the page to finish loading\u003e\",\n    \"status_timeout\": \"\u003cmaximum seconds to wait for the main HTTP request to return\u003e\",\n    \"print_timeout\": \"\u003cmaximum seconds to wait for the PDF to 'print'\u003e\",\n    \"options\": {\n        # This is passed directly through to Chromium as options to the Page.printToPDF\n        # function. You may omit this entirely, or use any of the options from this URL:\n        # https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF\n        \"landscape\": true,\n        \"scale\": 0.8,\n        ... etc ...\n    }\n}\n```\n\n### Errors\n\nPDF (or other CDP response) exceeded the `max_size` set\n\n```json\n{\n    \"url\": \"https://www.google.com\",\n    \"max_size\": \"\u003cwhatever you set it to\u003e\",\n    \"error\": \"PDF exceeded maximum size\"\n}\n```\n\nTimeout waiting for Chromium to reply with the 'printed' PDF\n\n```json\n{\n    \"url\": \"https://www.google.com\",\n    \"print_timeout\": \"\u003cwhatever you set it to\u003e\",\n    \"error\": \"Timeout printing PDF\"\n}\n```\n\n## Healthcheck\n\nYou may HTTP GET the `/healthcheck/` endpoint to have the server perform a cursory healthcheck to ensure it can communicate with Chromium's DevTools API.\n\nReturns a status code of `200` if communication is successful and `500` if not.\n\n## Memory and concurrency\n\nChrom(e|ium) has a tendency to guzzle as much memory as it can get its hands on. You may find that this docker image crashes with an error along the lines of:\n\n```\nFATAL:memory.cc(22)] Out of memory. size=262144\n```\n\nIn this case, you will need to increase the shared memory size using the `--shm-size=512M` command. The default is only `64M` so you may want to experiment with what size suits you, based on how many tabs you're likely to have open at once.\n\nAnother potential issue is how many tabs you really want to have open at once. This is by default limited to 10, but you can set this to whatever you like, using the `PDF_CONCURRENCY` environment variable:\n\n```\ndocker run -ti --rm -p 8080:8080 -e PDF_CONCURRENCY=2 flyte/chromium-pdf-api\n```\n\nThis can help to plan for the amount of memory your container is going to use, although it really depends how much memory the site you're PDFing uses as well.\n\n## Cooperative Loading\n\nSometimes you'll want to make sure that any asynchronous content has completed loading before creating your PDF. You may do this by adding an HTML input element to the page with class `pdfloading`, then changing its value to `loaded` using JavaScript once your content is fully ready.\n\nFor example:\n\n```html\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eMy PDF\u003c/h1\u003e\n        \u003cinput type=\"hidden\" id=\"loading1\" class=\"pdfloading\" value=\"loading\" /\u003e\n        \u003cinput type=\"hidden\" id=\"loading2\" class=\"pdfloading\" value=\"loading\" /\u003e\n        \u003cscript\u003e\n            setTimeout(function() {\n                document.getElementById(\"loading1\").value = \"loaded\"\n            }, 5000)\n        \u003c/script\u003e\n        \u003cscript\u003e\n            setTimeout(function() {\n                document.getElementById(\"loading2\").value = \"loaded\"\n            }, 8000)\n        \u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyte%2Fchromium-pdf-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyte%2Fchromium-pdf-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyte%2Fchromium-pdf-api/lists"}