{"id":17688258,"url":"https://github.com/neroist/nimipdf","last_synced_at":"2025-04-09T16:18:14.661Z","repository":{"id":160788025,"uuid":"635600831","full_name":"neroist/nimipdf","owner":"neroist","description":"PDF backend for nimib","archived":false,"fork":false,"pushed_at":"2023-05-14T18:49:05.000Z","size":199,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:18:02.585Z","etag":null,"topics":["library","nim","nim-lang","nimib","nimibex","nimibex-extension","pdf","pdf-generation"],"latest_commit_sha":null,"homepage":"https://neroist.github.io/nimipdf/","language":"Nim","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/neroist.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-03T03:37:45.000Z","updated_at":"2024-09-12T13:20:49.000Z","dependencies_parsed_at":"2023-06-09T17:45:20.671Z","dependency_job_id":null,"html_url":"https://github.com/neroist/nimipdf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neroist%2Fnimipdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neroist%2Fnimipdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neroist%2Fnimipdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neroist%2Fnimipdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neroist","download_url":"https://codeload.github.com/neroist/nimipdf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065280,"owners_count":21041872,"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","nim","nim-lang","nimib","nimibex","nimibex-extension","pdf","pdf-generation"],"created_at":"2024-10-24T11:44:00.371Z","updated_at":"2025-04-09T16:18:14.634Z","avatar_url":"https://github.com/neroist.png","language":"Nim","readme":"\n# 📄 Nimipdf\n\nNimipdf is a nimibex extension that adds a PDF backend for\n[nimib](https://github.com/pietroppeter/nimib). This allows you to generate\nPDFs with nimib (in fact, you may be reading one right now!).\n\n## ⬇️ Installation\n\nInstall nimipdf with Nimble:\n\n```sh\nnimble install nimipdf\n```\n\n## 🦵 Limitations\n\nEmoji's don't work properly, so Twemoji is used instead of your OS's native\nemoji set.\n\nIn addition, images *might* require the absolute path to the image.\n\n## 📝 How Nimipdf Works!\n\nPDFs are generated through the use of libwkhtmltox\n[Nim bindings](https://github.com/neroist/nim-wkhtmltox). This allows for\nquick and simple PDF generation while also providing easy customizaton.\n\nNimipdf provides two main templates, so lets talk about those.\n\n- `nbInitPdf`:\n  - When calling `nbInitPdf`, libwkhtmltox (and nimib) are initalized, and\n    the converter, global settings, and object settings are created and\n    attached onto the injected `nbPdf` variable.\n\n- `nbSavePdf`:\n  - When saving via `nbSavePdf`, nimipdf takes the rendered html\n    output of your nimib document and converts it into a PDF using\n    libwkhtmltox.\n\n    Before this, however, the `out` and `documentTitle` global settings are\n    set to the nimib document's filename (`nb.filename`) and title\n    (`doc.context[\"title\"]`) respectively.\n\n    Libwkhtmltopdf is also de-initialized when calling `nbSavePdf`.\n\n## 🐝 API\n\n- `nbInitPdf` injects a `nbPdf` variable\n  - `nbPdf.converter` contains the wkhtmltopdf converter used to generate the PDF.\n  - `nbPdf.globalSettings` contains the wkhtmltopdf global settings. A list\n     of available settings to set can be found\n     [here](https://wkhtmltopdf.org/libwkhtmltox/pagesettings.html#pagePdfGlobal),\n     and can be set via `nbPdf.setGlobalSetting(name, value)`\n  - `nbPdf.objectSettings` contains the wkhtmltopdf object settings. A list\n     of available settings to set can be also found\n     [here](https://wkhtmltopdf.org/libwkhtmltox/pagesettings.html#pagePdfObject),\n     and can be set via a similar way to global settings\n     (`setObjectSetting`)\n- use `nbPageBreak` to insert a page break\n- use `nbSavePdf` to save document\n\nThe `pdf` submodule from\n[nimwkhtmltox](https://github.com/neroist/nim-wkhtmltox) is exported, so\nyou can also use functions and methods from wkhtmltox aswell to further\nmodify nimipdf's behavior (for example, adding callback functions to\n`nbPdf.converter`).\n\n## ⁉️ How to Use\n\n- Initialize nimipdf (and wkhtmltopdf) with `nbInitPdf`\n- Write your usual nimib code (nbText, nbCode, etc.)\n- Save the PDF using `nbSavePdf` (this also de-inits wkhtmltopdf)\n\nThere is a more \"hands-on\" example in the following section.\n\n## 👋 Get Started/Example\n\nTo start, firstly import the library and nimib (of course...)\n\n\n\n```nim\nimport nimipdf\nimport nimib\n```\n\n\n\n\nInitialize nimipdf (and nimib) using `nbInitPdf`.\n\n\n\n```nim\nnbInitPdf\n```\n\n\n\n\nNext, add your usual nimib code (nbCode, nbText, etc.)\n\nHere, we'll use\n[hello.nim](https://github.com/pietroppeter/nimib/blob/main/docsrc/hello.nim):\n\n\n\n```nim\nimport strformat, strutils\n\nnbText: \"\"\"\n  ## Secret talk with a computer\n  Let me show you how to talk with the computer like a [real hacker](https://mango.pdf.zone/)\n  and incidentally you might learn the basics of [nimib](https://github.com/pietroppeter/nimib).\n  ### A secret message\n  Inside this document is hidden a secret message. I will ask the computer to spit it out:\n  \"\"\"\n\nlet secret = [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100]\n\nnbCode:\n  echo secret\n\nnbText: fmt\"\"\"\n  what does this integer sequence mean?\n  Am I supposed to [recognize it](https://oeis.org/search?q={secret.join(\"%2C+\")}\u0026language=english\u0026go=Search)?\n\n  ### A cryptoanalytic weapon\n  Luckily I happen to have a [nim](https://nim-lang.org/) implementation of\n  a recently declassified top-secret cryptoanalytic weapon:\"\"\"\n\nnbCode:\n  func decode(secret: openArray[int]): string =\n    ## classified by NSA as \u003cstrong\u003eTOP SECRET\u003c/strong\u003e\n    for c in secret:\n      result.add char(c)\n\nnbText: \"\"\"\n    ### The great revelation\n    Now I can just apply it to my secret message and\n    finally decrypt what the computer wants to tell me:\"\"\"\n\nnbCode:\n  let msg = decode secret\n  echo msg  # what will it say?\n\nnbText:\n  fmt\"_Hey_, there must be a bug somewhere, the message (`{msg}`) is not even addressed to me!\"\n```\n\n\n\n\nFinally, save the PDF using `nbSavePdf`.\n\n\n\n```nim\nnbSavePdf\n```\n\n\n\n\nThe generated pdf file can be found [here](https://neroist.github.io/nimipdf/hello.pdf)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneroist%2Fnimipdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneroist%2Fnimipdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneroist%2Fnimipdf/lists"}