{"id":21542410,"url":"https://github.com/kool-dev/pdf","last_synced_at":"2025-04-10T04:25:13.462Z","repository":{"id":38301304,"uuid":"293072248","full_name":"kool-dev/pdf","owner":"kool-dev","description":"Micro-service for generating PDF files using Puppeteer with an Express API","archived":false,"fork":false,"pushed_at":"2024-07-04T16:59:00.000Z","size":80,"stargazers_count":20,"open_issues_count":8,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T05:43:43.423Z","etag":null,"topics":["docker","docker-compose","hacktoberfest","node","pdf","puppeteer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kool-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-09-05T12:33:35.000Z","updated_at":"2024-10-30T19:33:19.000Z","dependencies_parsed_at":"2023-09-26T04:27:07.596Z","dependency_job_id":null,"html_url":"https://github.com/kool-dev/pdf","commit_stats":{"total_commits":42,"total_committers":6,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"89e6d03e54b8cbc7dabb0ee98d2e66db55e4f657"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kool-dev%2Fpdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kool-dev%2Fpdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kool-dev%2Fpdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kool-dev%2Fpdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kool-dev","download_url":"https://codeload.github.com/kool-dev/pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248156162,"owners_count":21056783,"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":["docker","docker-compose","hacktoberfest","node","pdf","puppeteer"],"created_at":"2024-11-24T05:09:32.304Z","updated_at":"2025-04-10T04:25:13.439Z","avatar_url":"https://github.com/kool-dev.png","language":"JavaScript","readme":"# PDF microservice\n\nPDF generation micro-service. Super easy to add on `kool` and `docker-compose` based environments, for generating PDFs from any URLs or given HTML content.\n\n## Getting started using this microservice in your project\n\nIf you use Docker Compose (hopefully with [`kool`](https://github.com/kool-dev/kool) to make things simpler) you can get PDF generation on your project with a few simple steps:\n\n- Add the service to your `docker-compose.yml` file:\n\n```yml\n  pdf:\n    image: \"kooldev/pdf:1.0\"\n    ports:\n      - \"3000:3000\"\n```\n\n- After starting the service containers (with either `kool start` or `docker-compose up -d`), you can already start using the microservice to make PDFs! Example using PHP:\n\n```php\nuse GuzzleHttp\\Client;\n\n// the hostname is the docker-compose service name, or an alias you add to your docker network\n$pdf = (new Client())-\u003epost('http://pdf:3000/from-html', [\n    'form_params' =\u003e [\n        'html' =\u003e '\u003ch1\u003eThis is my super kool HTML that I want to turn into an awesome PDF file!\u003c/h1\u003e \u003cp\u003e This is a very silly example, but you get the idea of how powerful this is \u003cb\u003e:)\u003c/b\u003e \u003c/p\u003e',\n        'options' =\u003e json_encode([\n            'format' =\u003e 'A4',\n            'printBackground' =\u003e false,\n        ]),\n    ],\n])-\u003egetBody();\n\nfile_put_contents('path/to/my/super-kool.pdf', $pdf);\n```\n\n* Important to notice, the code above assumes you are running it from within another container in the same Docker Compose application so the `pdf` domain resolves to our microservice.\n\n* The `options` should be a json data type\n\n* You can see all these `options` in [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagepdfoptions)\n\n## Getting started on developing locally this microservice\n\nTo get started with development locally (using [`kool`](https://github.com/kool-dev/kool), of course!):\n\n- Fork the repo.\n- Clone the fork.\n- `kool run yarn install` - this will install dependencies.\n- `kool start` - will get up the API on localhost:3000.\n- `docker-compose logs -f` - tails the API logs.\n\nIn order to manage dependencies and run commands, please remind of using `kool run yarn` to stick with one single yarn version.\n\n## Roadmap\n\nSoon to be added wishes:\n\n- Parameters to better control Javascript execution/wait condition.\n- Conversion to images also.\n- Got some _kool_ feature you are not seeing? Please open a ticket to suggest it!\n\n## API\n\nThe API will provide endpoints for generating PDFs on the fly and returning them right away.\n\n#### From an URL\n\nEndpoint: `GET /from-url?url=`\n\nParameters:\n - `url`: URL of the page we want to convert to PDF.\n\nReturns the rendered PDF from the provided URL, or a JSON with an error message and status.\n\n#### Health status\n\nEndpoint: `GET /health`\n\nReturns the current status in JSON. Status code may be 200 (active) or 503 (not ready).\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkool-dev%2Fpdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkool-dev%2Fpdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkool-dev%2Fpdf/lists"}