$ gem install hexapdf
Latest version 0.27.0 released on 2022-11-18
HexaPDF is AGPL Open Source, a commercial license is available Buy HexaPDF
"HexaPDF is invaluable for our business. It helps us quickly and efficiently manipulate hundreds of thousands of PDFs. Support for HexaPDF is always responsive, helpful, and easily the best support we've received from any of the software vendors we've worked with.
I highly recommend HexaPDF to any business that needs a fast and rock solid way to work with PDFs."
"The daisyBill platform processes tens of thousands of PDF files a week. Before HexaPDF, malformed PDF files required several approaches to fix. When we introduced HexaPDF, it already did way better then some of our other tools. Over the course of a few months, we worked with HexaPDF's author to improve HexaPDF's ability to process and repair malformed PDFs; this drastically streamlined our PDF tool kit.
When it comes to repairing malformed PDF files I highly recommend HexaPDF, plus it's in Ruby so the code is easy to write!"
HexaPDF includes facilities for creating PDF documents from scratch. Use the low-level canvas API for drawing graphics and outputting text if you want full control over every aspect. Or use the built-in document layout engine that provides a convenient, word-processor like way of creating complex documents, including automatically flowing text around other content.
require 'hexapdf' doc = HexaPDF::Document.new doc.pages.add.canvas. font("Times", size: 30). text("Hello World", at: [200, 300]) doc.write("hello-world.pdf")
require 'hexapdf' HexaPDF::Composer.create("hello-world.pdf") do |composer| composer.text("Hello World", font_size: 30, align: :center, valign: :center) end
HexaPDF supports all password based encryption mechanisms, including AES 256bit, when reading and writing PDF files.
There is also support for digitally signing a PDF using a certificate and for verifying digital signatures.
require 'hexapdf' doc = HexaPDF::Document.open(input_file) doc.pages.move(3, 5) doc.pages.delete_at(2) new_page = doc.pages.insert(-2) new_page.canvas.circle(200, 200, 30).fill doc.write(output_file)
require 'hexapdf' doc = HexaPDF::Document.open(input_file) doc.acro_form.field_by_name('firstname').value = 'Thomas' doc.acro_form.field_by_name('city').value = 'Vienna' doc.write(output_file)
HexaPDF allows extracting various parts of a PDF file, for example text from a page, attached files, embedded images, ...
HexaPDF writes output PDF files as compactly as possible. Additionally, it can lossleesly optimize existing PDF files to reduce their file size.
Ready to start with HexaPDF? Tutorials
HexaPDF is licensed under the GNU Affero General Public License (AGPL), an open source license. It allows you to use HexaPDF for free as long as you adhere to the license. Additionally, there is also a commercial license.
The AGPL puts some restrictions in place to make sure that the community benefits from changes to the code. For example, if you use HexaPDF in an application and distribute that application, you have to make the source code of the whole application available under the AGPL. The same applies if your application is used over a network. Please refer to the license for details.
If you don't want to adhere to the AGPL or can't (e.g. because you can't make the code that uses HexaPDF available under the AGPL), then you need to purchase a commercial license.