{"id":13394905,"url":"https://github.com/gettalong/hexapdf","last_synced_at":"2025-05-13T18:05:52.521Z","repository":{"id":20629174,"uuid":"23910841","full_name":"gettalong/hexapdf","owner":"gettalong","description":"Versatile PDF creation and manipulation for Ruby","archived":false,"fork":false,"pushed_at":"2025-05-12T10:34:29.000Z","size":6145,"stargazers_count":1293,"open_issues_count":11,"forks_count":73,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-12T11:41:58.122Z","etag":null,"topics":["pdf","pdf-generation","pdf-manipulation","ruby"],"latest_commit_sha":null,"homepage":"https://hexapdf.gettalong.org","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gettalong.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null},"funding":{"github":"gettalong","patreon":"gettalong"}},"created_at":"2014-09-11T08:45:34.000Z","updated_at":"2025-05-06T14:19:04.000Z","dependencies_parsed_at":"2024-05-01T10:35:55.776Z","dependency_job_id":"0e97c5a9-2d3a-4b90-809a-ec19974f1205","html_url":"https://github.com/gettalong/hexapdf","commit_stats":{"total_commits":1844,"total_committers":3,"mean_commits":614.6666666666666,"dds":"0.0010845986984815426","last_synced_commit":"7305f0994c5da3d14eb7002a628716a796e0a400"},"previous_names":[],"tags_count":105,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettalong%2Fhexapdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettalong%2Fhexapdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettalong%2Fhexapdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettalong%2Fhexapdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gettalong","download_url":"https://codeload.github.com/gettalong/hexapdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253735763,"owners_count":21955777,"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":["pdf","pdf-generation","pdf-manipulation","ruby"],"created_at":"2024-07-30T17:01:35.745Z","updated_at":"2025-05-13T18:05:52.513Z","avatar_url":"https://github.com/gettalong.png","language":"Ruby","readme":"# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby\n\nHexaPDF is a pure Ruby library with an accompanying application for working with PDF files. It was\ndesigned with ease of use and performance in mind. It uses lazy loading and lazy computing when\npossible and tries to produce small PDF files by default.\n\nIn short, it allows\n\n* **creating** new PDF files,\n* **manipulating** existing PDF files,\n* **merging** multiple PDF files into one,\n* **extracting** meta information, text, images and files from PDF files,\n* **securing** PDF files by encrypting or signing them and\n* **optimizing** PDF files for smaller file size or other criteria.\n\nHexaPDF is available under two license, the AGPL and a commercial license, see the [License\nsection](#License) for details.\n\n\n## Features\n\n* Pure Ruby\n* Minimal dependencies ('cmdparse' for `hexapdf` binary, 'geom2d' for document layout)\n* Easy to use, Ruby-esque API\n* Fully tested with 100% code coverage\n* Low-level API with high-level convenience interface on top\n* Complete [canvas API] which directly maps to PDF internal operators\n* Path drawing operations like lines, polylines, rectangles, bézier curves, arcs, ...\n* Embedding images in JPEG (lossy), PNG (lossless) and PDF (vector) format with support for\n  transparency\n* UTF-8 text via TrueType fonts and support for font subsetting\n* High-level [document composition engine] with automatic content layout\n  * [Flowing text] around other content\n  * Pre-define [styles] and assign to multiple content boxes\n  * Automatic page breaks\n  * [(Un)ordered lists]\n  * [Multi-column layout]\n* [PDF forms] (AcroForm) with Adobe Reader like appearance generation\n* Annotations\n* [Document outline]\n* [Attaching files] to the whole PDF or individual pages, extracting files\n* Image extraction\n* [Encryption] including PDF 2.0 features (e.g. AES256)\n* [Digital signatures]\n* [File size optimization]\n* PDF object validation\n* [`hexapdf` binary][hp] for most common PDF manipulation tasks\n\n\n[canvas API]: https://hexapdf.gettalong.org/documentation/api/HexaPDF/Content/Canvas.html\n[document composition engine]: https://hexapdf.gettalong.org/documentation/document-creation/document-layout.html\n[flowing text]: https://hexapdf.gettalong.org/examples/frame_text_flow.html\n[styles]: https://hexapdf.gettalong.org/documentation/api/HexaPDF/Layout/Style/index.html\n[(un)ordered lists]: https://hexapdf.gettalong.org/documentation/api/HexaPDF/Layout/ListBox.html\n[multi-column layout]: https://hexapdf.gettalong.org/documentation/api/HexaPDF/Layout/ColumnBox.html\n[PDF forms]: https://hexapdf.gettalong.org/documentation/interactive-forms/index.html\n[Document outline]: https://hexapdf.gettalong.org/documentation/outline/index.html\n[attaching files]: https://hexapdf.gettalong.org/documentation/api/HexaPDF/Document/Files.html\n[Encryption]: https://hexapdf.gettalong.org/documentation/encryption/index.html\n[Digital Signatures]: https://hexapdf.gettalong.org/documentation/digital-signatures/index.html\n[File size optimization]: https://hexapdf.gettalong.org/documentation/benchmarks/optimization.html\n[hp]: https://hexapdf.gettalong.org/documentation/hexapdf.1.html\n\n\n## Usage\n\nThe HexaPDF distribution provides the library as well as the `hexapdf` application. The application\ncan be used to perform common tasks like merging PDF files, decrypting or encrypting PDF files and\nso on.\n\nWhen HexaPDF is used as a library, it can be used to do all the task that the command line\napplication does and much more. Here is a \"Hello World\" example that shows how to create a simple\nPDF file:\n\n~~~ ruby\nrequire 'hexapdf'\n\ndoc = HexaPDF::Document.new\ncanvas = doc.pages.add.canvas\ncanvas.font('Helvetica', size: 100)\ncanvas.text(\"Hello World!\", at: [20, 400])\ndoc.write(\"hello-world.pdf\")\n~~~\n\nFor detailed information have a look at the [HexaPDF website][website] where you will find the API\ndocumentation, example code and more.\n\nIt is recommend to use the HTML API documentation provided by the HexaPDF website as it is enhanced\nwith example graphics and PDF files and tightly integrated into the rest of the website.\n\n[website]: https://hexapdf.gettalong.org\n\n\n## Requirements and Installation\n\nSince HexaPDF is written in Ruby, a working Ruby installation is needed - see the\n[official installation documentation][rbinstall] for details. Note that you need Ruby version 2.6 or\nhigher as prior versions are not supported!\n\nHexaPDF works on all Ruby implementations that are CRuby compatible, e.g. TruffleRuby, and on any\nplatform supported by Ruby (Linux, macOS, Windows, ...).\n\nApart from Ruby itself the HexaPDF library has only one external dependency `geom2d` which is\nwritten and provided by the HexaPDF authors. The `hexapdf` application has an additional dependency\non `cmdparse`, a command line parsing library.\n\nHexaPDF itself is distributed via Rubygems and therefore easily installable via `gem install\nhexapdf`.\n\n[rbinstall]: https://www.ruby-lang.org/en/documentation/installation/\n\n\n## Difference to Prawn\n\nThe main difference between HexaPDF and [Prawn] is that HexaPDF is a **full PDF library** whereas\nPrawn is a **library for generating content**.\n\nTo be more specific, it is easily possible to read an existing PDF with HexaPDF and modify parts of\nit before writing it out again. The modifications can be to the PDF object structure like removing\nsuperfluous annotations or the the content itself.\n\nPrawn has no such functionality. There is basic support for using a PDF as a template using the\n`pdf-reader` and `prawn-template` gems but support is very limited. However, Prawn has a very\nfeatureful API when it comes to creating content, for individual pages as well as across pages.\n\nIf you want to migrate from Prawn to HexaPDF, there is the [migration guide] with detailed\ninformation and examples, comparing the Prawn API to HexaPDF's equivalents.\n\n[migration guide]: https://hexapdf.gettalong.org/documentation/document-creation/migrating-from-prawn.html\n\nWhy use HexaPDF?\n\n* It has many more [features](#features) beside content creation that might come in handy (e.g. PDF\n  form creation, encryption, digital signatures, ...).\n\n* The architecture of HexaPDF is based on the object model of the PDF standard. This makes extending\n  HexaPDF very easy and allows for **reading PDF files for templating purposes**.\n\n* HexaPDF provides a high level API for **composing a document of individual elements** that are\n  automatically layouted. Such elements can be headers, paragraphs, code blocks, ... or links,\n  emphasized text and so on. These elements can be customized and additional element types easily\n  added.\n\n* In addition to being usable as a library, HexaPDF also comes with a command line tool for\n  manipulating PDFs. This tool is intended to be a replacement for tools like `pdftk` and the\n  various Poppler-based tools like `pdfinfo`, `pdfimages`, ...\n\n[Prawn]: https://prawnpdf.org\n[page canvas API]: https://hexapdf.gettalong.org/api/HexaPDF/Content/Canvas.html\n\n\n## Development\n\nClone the repository and then run `rake dev:setup`. This will install the needed Rubygem\ndependencies as well as make sure that all applications needed for the tests are available.\n\n\n## License\n\nAGPL - see the LICENSE file for licensing details. Commercial licenses are available at\n\u003chttps://gettalong.at/hexapdf/\u003e.\n\nA commercial license is needed as soon as HexaPDF is distributed with your software or remotely\naccessed via a network and you don't provide the source code of your application under the AGPL. For\nexample, if you serve PDFs on the fly in a web application.\n\nContact \u003csales@gettalong.at\u003e for more information!\n\nSome included files have a different license:\n\n* For the license of the included AFM files in the `data/hexapdf/afm` directory, see the file\n  `data/hexapdf/afm/MustRead.html`.\n\n* The files `test/data/encoding/{glyphlist.txt,zapfdingbats.txt}` are licensed under the Apache\n  License V2.0.\n\n* The file `test/data/fonts/Ubuntu-Title.ttf` is licensed under the SIL Open Font License.\n\n* The AES test vector files in `test/data/aes-test-vectors` have been created using the test vector\n  file available from \u003chttp://csrc.nist.gov/groups/STM/cavp/block-ciphers.html#test-vectors\u003e.\n\n* The license of the file `data/hexapdf/sRGB2014.icc` is available in the\n  `data/hexapdf/sRGB2014.icc.LICENSE` file.\n\n\n## Contributing\n\nSee \u003chttps://hexapdf.gettalong.org/contributing.html\u003e for more information.\n\n\n## Author\n\nThomas Leitner, \u003chttps://gettalong.org\u003e\n","funding_links":["https://github.com/sponsors/gettalong","https://patreon.com/gettalong"],"categories":["RUBY","Ruby","PDF generation","PDF","Libraries"],"sub_categories":["Ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettalong%2Fhexapdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgettalong%2Fhexapdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettalong%2Fhexapdf/lists"}