{"id":16162765,"url":"https://github.com/msrd0/genpdf-rs","last_synced_at":"2025-07-19T19:06:42.009Z","repository":{"id":47466844,"uuid":"372910606","full_name":"msrd0/genpdf-rs","owner":"msrd0","description":"Forked from https://sr.ht/~ireas/genpdf-rs/","archived":false,"fork":false,"pushed_at":"2022-01-08T12:16:13.000Z","size":464,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T08:30:29.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/msrd0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/Apache-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-01T17:25:28.000Z","updated_at":"2022-01-08T12:16:16.000Z","dependencies_parsed_at":"2022-08-27T00:32:27.412Z","dependency_job_id":null,"html_url":"https://github.com/msrd0/genpdf-rs","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/msrd0%2Fgenpdf-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msrd0%2Fgenpdf-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msrd0%2Fgenpdf-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msrd0%2Fgenpdf-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msrd0","download_url":"https://codeload.github.com/msrd0/genpdf-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589836,"owners_count":20963022,"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":[],"created_at":"2024-10-10T02:32:50.669Z","updated_at":"2025-04-07T03:49:38.159Z","avatar_url":"https://github.com/msrd0.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!---\nCopyright (C) 2020 Robin Krahl \u003crobin.krahl@ireas.org\u003e\nSPDX-License-Identifier: CC0-1.0\n--\u003e\n\n# genpdf-rs\n\nA user-friendly PDF generator written in pure Rust.\n\n[Documentation](https://docs.rs/genpdf)\n\n`genpdf` is a high-level PDF generator built on top of [`printpdf`][] and\n[`rusttype`][].  It takes care of the page layout and text alignment and\nrenders a document tree into a PDF document.  All of its dependencies are\nwritten in Rust, so you don’t need any pre-installed libraries or tools.\n\n[`printpdf`]: https://lib.rs/crates/printpdf\n[`rusttype`]: https://lib.rs/crates/rusttype\n\n\u003c!-- Keep in sync with src/lib.rs --\u003e\n```rust\n// Load a font from the file system\nlet font_family = genpdf::fonts::from_files(\"./fonts\", \"LiberationSans\", None)\n    .expect(\"Failed to load font family\");\n// Create a document and set the default font family\nlet mut doc = genpdf::Document::new(font_family);\n// Change the default settings\ndoc.set_title(\"Demo document\");\n// Customize the pages\nlet mut decorator = genpdf::SimplePageDecorator::new();\ndecorator.set_margins(10);\ndoc.set_page_decorator(decorator);\n// Add one or more elements\ndoc.push(genpdf::elements::Paragraph::new(\"This is a demo document.\"));\n// Render the document and write it to a file\ndoc.render_to_file(\"output.pdf\").expect(\"Failed to write PDF file\");\n```\n\nFor a complete example with all supported elements, see the\n[`examples/demo.rs`][] file that generates [this PDF document][].\n\n[`examples/demo.rs`]: https://git.sr.ht/~ireas/genpdf-rs/tree/master/examples/demo.rs\n[this PDF document]: https://genpdf-rs.ireas.org/examples/demo.pdf\n\nFor more information, see the [API documentation](https://docs.rs/genpdf).\n\n## Features\n\n- PDF generation in pure Rust\n- Text rendering with support for setting the font family, style and size as\n  well as the text color and text effects (bold or italic) and with kerning\n- Text wrapping at word boundaries and optional hyphenation\n- Layout of elements sequentially or in tables\n- Rudimentary support for shapes\n- Page headers and custom page decorations\n- Embedding images (scale, position, rotate).\n\n## Cargo Features\n\nThis crate has the following Cargo features (deactivated per default):\n\n- `images`: Adds support for embedding images using the [`image`][] crate.\n- `hyphenation`:  Adds support for hyphenation using the [`hyphenation`][] crate.\n\n[`hyphenation`]: https://lib.rs/crates/hyphenation\n[`image`]: https://lib.rs/crates/image\n\n## Roadmap\n\nThese features are currently not supported but planned for future versions:\n- Improved support for drawing shapes\n- Advanced text formatting\n\nSee also the [`genpdf-rs` issue tracker](https://todo.sr.ht/~ireas/genpdf-rs).\n\n## Alternatives\n\n- [`printpdf`][] is the low-level PDF library used by `genpdf`.  It provides\n  more control over the generated document, but you have to take care of all\n  details like calculating the width and height of the rendered text, arranging\n  the elements and distributing them on multiple pages.\n- [`latex`][] generates LaTeX documents from Rust.  It requires a LaTex\n  installation to generate the PDF files.  Also, escaping user input is a\n  non-trivial problem and not supported by the crate.\n- [`tectonic`][] is a TeX engine based on XeTeX.  It is partly written in C and\n  has some non-Rust dependencies.\n- [`wkhtmltopdf`][] generates PDF documents from HTML using the `wkhtmltox`\n  library.  It requires a pre-installed library and does not support custom\n  elements.\n\n[`latex`]: https://lib.rs/crates/latex\n[`tectonic`]: https://lib.rs/crates/tectonic\n[`wkhtmltopdf`]: https://lib.rs/crates/wkhtmltopdf\n\n## Minimum Supported Rust Version\n\nThis crate supports at least Rust 1.45.0 or later.\n\n## Contributing\n\nContributions to this project are welcome!  Please submit patches to the\nmailing list [~ireas/public-inbox@lists.sr.ht][] ([archive][]) using the\n`[PATCH genpdf-rs]` subject prefix.  For more information, see the\n[Contributing Guide][].\n\n[~ireas/public-inbox@lists.sr.ht]: mailto:~ireas/public-inbox@lists.sr.ht\n[archive]: https://lists.sr.ht/~ireas/public-inbox\n[Contributing Guide]: https://man.sr.ht/~ireas/guides/contributing.md\n\nIf you are looking for a good starting point, have a look at the [issues with\nthe label “good first issue”][issues] in `genpdf-rs`’s issue tracker.\n\n[issues]: https://todo.sr.ht/~ireas/genpdf-rs?search=label:%22good%20first%20issue%22%20status%3Aopen\n\n## Contact\n\nFor bug reports, feature requests and other messages, please send a mail to\n[~ireas/public-inbox@lists.sr.ht][] ([archive][]) using the `[genpdf-rs]`\nprefix in the subject.\n\n## License\n\nThis project is dual-licensed under the [Apache-2.0][] and [MIT][] licenses.\nThe documentation and examples contained in this repository are licensed under\nthe [Creative Commons Zero][CC0] license.  You can find a copy of the license\ntexts in the `LICENSES` directory.\n\n`genpdf-rs` complies with [version 3.0 of the REUSE specification][reuse].\n\n[Apache-2.0]: https://opensource.org/licenses/Apache-2.0\n[MIT]: https://opensource.org/licenses/MIT\n[CC0]: https://creativecommons.org/publicdomain/zero/1.0/\n[reuse]: https://reuse.software/practices/3.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsrd0%2Fgenpdf-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsrd0%2Fgenpdf-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsrd0%2Fgenpdf-rs/lists"}