{"id":22559596,"url":"https://github.com/random-guys/pdfmills","last_synced_at":"2025-06-17T22:34:26.614Z","repository":{"id":44049865,"uuid":"218904382","full_name":"random-guys/pdfmills","owner":"random-guys","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-04T23:53:27.000Z","size":1992,"stargazers_count":7,"open_issues_count":6,"forks_count":6,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-05-11T21:16:52.070Z","etag":null,"topics":["library","pdf-generation","pdfkit"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/random-guys.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-11-01T03:12:58.000Z","updated_at":"2024-08-05T20:13:14.000Z","dependencies_parsed_at":"2023-02-03T00:46:06.810Z","dependency_job_id":null,"html_url":"https://github.com/random-guys/pdfmills","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/random-guys/pdfmills","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fpdfmills","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fpdfmills/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fpdfmills/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fpdfmills/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/random-guys","download_url":"https://codeload.github.com/random-guys/pdfmills/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fpdfmills/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260450826,"owners_count":23011156,"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":["library","pdf-generation","pdfkit"],"created_at":"2024-12-07T21:07:37.478Z","updated_at":"2025-06-17T22:34:21.603Z","avatar_url":"https://github.com/random-guys.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pdfmills\n\nA simple DSL wrapper around [pdfkit](https://github.com/foliojs/pdfkit)\n\n## What's inside\n\n- Elements:\n  - `Text` or `Paragraph`s\n  - `Image`s\n- Layouts:\n  - `Block`\n  - `Flex`\n  - `RatioFlex`\n  - `EqualFlex`\n- Spacing:\n  - `LineBreaks` for vertical spaces\n  - `Margin`\n  - `Padding`\n- Automatic page management\n\n## How to install\n\n```sh\nyarn add @random-guys/pdfmills\n```\n\nor\n\n```sh\nnpm i @random-guys/pdfmills\n```\n\n## Get Started\n\n```ts\nimport { block, Text } from \"@random-guys/pdfmills\";\n\n// arrange elements vertically\nconst divStyle: BlockStyle = {\n  display: \"block\",\n  margin: 0\n};\n\nconst flexStyle: FlexStyle = {\n  display: \"flex\"\n};\n\ndiv(\n  { ...divStyle, margin: 4 },\n  row({\n    style: flexStyle,\n    elements: [\n      col(p(\"START DATE\"), [\"right\"], 60),\n      col(p(\"ACCOUNT NUMBER\", alignRight), [\"right\", \"left\"], 100),\n      col(p(\"INCOME\", alignRight), [\"left\"], 60)\n    ]\n  }),\n  row({\n    style: flexStyle,\n    elements: [\n      col(p(\"12/03/07\", { ...headerFont, align: \"left\" }), [\"right\"], 60),\n      col(p(\"0087567843\", headerFont), [\"right\", \"left\"], 100),\n      col(p(\"₦250,000\", headerFont), [\"left\"], 60)\n    ]\n  }),\n  br(20),\n  row({\n    style: flexStyle,\n    elements: [\n      col(p(\"END DATE\"), [\"right\"], 60),\n      col(p(\"BALANCE\", alignRight), [\"right\", \"left\"], 100),\n      col(p(\"INCOME\", alignRight), [\"left\"], 60)\n    ]\n  }),\n  row({\n    style: flexStyle,\n    elements: [\n      col(p(\"12/03/07\", { ...headerFont, align: \"left\" }), [\"right\"], 60),\n      col(p(\"₦560,000\", headerFont), [\"right\", \"left\"], 100),\n      col(p(\"₦25,000\", headerFont), [\"left\"], 60)\n    ]\n  })\n);\n\n// arrange elements horizontally\nconst headerFont: FontStyle = { ...alignRight, fontColor: [130, 134, 145] };\nrow({\n  style: flexStyle,\n  elements: [\n    col(p(\"12/03/07\", { ...headerFont, align: \"left\" }), [\"right\"], 60),\n    col(p(\"0087567843\", headerFont), [\"right\", \"left\"], 100),\n    col(p(\"₦250,000\", headerFont), [\"left\"], 60)\n  ]\n});\n\n// load the element\nconst elements = [firstRow, br(50), secondRow, br(40), thirdRow];\n\n// write the elements to the buffer\nrender(context, elements);\n\n// you can write the buffer to the file stream\nsave(context.raw, \"output.pdf\");\n\n// you can also upload the file to Azure blob storage\nimport { Blobber } from \"@random-guys/blobber\";\nimport uuid from \"uuid/v4\";\n\nconst tempName = `${uuid()}.pdf`;\nconst uploader = new Blobber\u003cany\u003e(\"reports\");\ncontext.raw.end();\nreturn await uploader.streamLocalFile(tempName, this.context.raw);\n```\n\nCheckout the [examples](https://github.com/random-guys/pdfmills/tree/develop/examples) folder for real life examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandom-guys%2Fpdfmills","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandom-guys%2Fpdfmills","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandom-guys%2Fpdfmills/lists"}