{"id":16943521,"url":"https://github.com/jmettraux/slipdf","last_synced_at":"2026-01-23T06:20:38.600Z","repository":{"id":46963982,"uuid":"111526352","full_name":"jmettraux/slipdf","owner":"jmettraux","description":"Slim inspired template language on top of pdfmake (JS)","archived":false,"fork":false,"pushed_at":"2022-07-20T00:50:14.000Z","size":5793,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-14T13:56:31.866Z","etag":null,"topics":["javascript","pdf","pdfmake","slim"],"latest_commit_sha":null,"homepage":null,"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/jmettraux.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-21T09:20:07.000Z","updated_at":"2023-07-05T22:36:20.000Z","dependencies_parsed_at":"2022-09-07T22:22:06.509Z","dependency_job_id":null,"html_url":"https://github.com/jmettraux/slipdf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jmettraux/slipdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmettraux%2Fslipdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmettraux%2Fslipdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmettraux%2Fslipdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmettraux%2Fslipdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmettraux","download_url":"https://codeload.github.com/jmettraux/slipdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmettraux%2Fslipdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28682259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: 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":["javascript","pdf","pdfmake","slim"],"created_at":"2024-10-13T21:14:38.159Z","updated_at":"2026-01-23T06:20:38.577Z","avatar_url":"https://github.com/jmettraux.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# slipdf\n\nA [Slim](http://slim-lang.com/) inspired templating system on top of [pdfmake](http://pdfmake.org/#/).\n\n## An example\n\n```slim\n// example.slim\n\ndocument pageSize='A4'\n\n  header\n  footer\n\n  content\n    p This is template #{template}\n    - users.forEach(function(user) {\n      p.name= user.name\n      - [ 'alpha', 'bravo' ].forEach(function(k) {\n        p.key= k\n```\n\n```html\n\u003cscript src=\"/scripts/pdfmake-0.1.34.min.js\" async=\"true\"\u003e\u003c/script\u003e\n\u003cscript src=\"slip-1.0.0.pdf\"\u003e\u003c/script\u003e\n```\n\n```js\n// preparation work, grab the example.slim via the Fetch API\n\nvar exampleSlim = null;\n\nfetch('/slips/example.slim')\n  .then(function(res) { return res.text() })\n  .then(function(txt) { exampleSlim = txt; });\n\n// ...\n\n// later on, generation time\n\nvar exampleTemplate =\n  Slipdf.compile(exampleSlim);\nvar exampleDocument =\n  exampleTemplate({ users: [\n    { name: 'Alice' },\n    { name: 'Bob' } ] });\n\nvar examplePdf = pdfMake.createPdf(exampleDocument);\n\nexamplePdf.open();\n  // open the PDF immediately, in the browser\n//examplePdf.getBuffer(function(exampleBuffer) { /* ... */ });\n  // grab the buffer and deal with it ...\nexamplePdf.getDataUrl(function(dataUrl) { /* ... */ });\n  // turn the PDF into a data URI and ...\n```\n\n### images\n\nImages are to be added first to the Slipdf library itself, for example:\n\n```js\nSlipdf.addDataUrl('darts', '/images/gecbl/darts.png');\nSlipdf.addDataUrl('shield', '/images/shield.jpg');\nSlipdf.addDataUrl('office', 'https://images.example.org/office.png');\n```\n\nSlipdf then fetches the images and turns them into dataURLs. Those URLs can then be referenced in the Slim document as in:\n\n```slim\n  p\n    | This is our new office:\n    img src=(dataUrls.office)\n```\n\nAlthough mimicking the img HTML tag, the slip img tag accepts the PdfMake attributes (width, height, fit, ...) see under \"Images\" in the [PdfMake documentation](http://pdfmake.org/#/gettingstarted).\n\nUsing `img src=(dataUrls.office)` is fine, but if the `img` is wrapped in a loop, the dataURL gets copied N times and the size of the resulting PDF grows. It is better to use the `images` \"registration\" tag above in the slip document and then to reference the image in the `img` src, as in:\n\n```slim\ndocument(\n  pageSize='A4'\n  pageOrientation='landscape'\n  pageMargins=[ 14, 21, 14, 7 * 14 ]\n  defaultStyle={ font: 'HelveticaNeue' }\n)\n\n  colours\n    blue= '#002567'\n    white= '#ffffff'\n\n  images\n    foggy= dataUrls.foggy\n    star= dataUrls.star\n\n  styles\n    entry= { color: colours.white, fillColor: colours.blue, fontSize: 21 }\n\n  background\n    div\n      img src=\"foggy\" width=(1260)\n\n  content\n    - entries.forEach(function(e, i) {\n      p.entry\n        | * #{e.name}\n        - if e.starry\n          img src=\"star\"\n```\n\nEven if there are hundreds of starry entries, the weight of the star image (as a dataURL) is only counted once in the resulting PDF.\n\n\n### tables\n\nWarning about tables and `colspan` and `rowspan`: pdfmake requires us to have the overridden `td` cells.\n\nBad (will fail badly):\n```slim\n  table\n    tr\n      td colspan=2 A\n      td B\n    tr\n      td a\n      td b\n      td c\n```\n\nGood:\n```slim\n  table\n    tr\n      td colspan=2 A\n      td (will get overriden)\n      td B\n    tr\n      td a\n      td b\n      td c\n```\n\nIt doesn't matter with colspan at the right of the table:\n```slim\n  table\n    tr\n      td colspan=3 A\n      / no need for a ghost td\n      / no need for a ghost td\n    tr\n      td a\n      td b\n      td c\n```\n\n\n## License\n\nMIT, see [LICENSE.txt](LICENSE.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmettraux%2Fslipdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmettraux%2Fslipdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmettraux%2Fslipdf/lists"}