HexaPDF 0.35.0 - Fallback Fonts Published on

This release contains many small features and fixes and breaking changes. So make sure you read the changelog before upgrading!

The most notable additions and changes are:

  • The document layout engine gained support for fallback fonts. Just define the fallback fonts using the new configuration option ‘font.fallback’ and you are set.

    fallback font example

    The fallback font support is also used when generating appearances for AcroForm text fields.

  • It is now possible to use the document layout functionality for a single canvas/page via the new HexaPDF::Content::CanvasComposer class, easily instantiated via canvas.composer.

  • The style properties ‘align’ and ‘valign’ have been renamed (breaking change) to ‘text_align’ and ‘text_valign’ so that the old names can be used for box placement. With the addition of the style property ‘mask_mode’ one has now even more control over box placement, e.g. overlaying boxes is now possible (see the added example).

  • The new ‘psd’ command for hexapdf inspect provides easier to read output for page content streams, e.g. by decoding the text output parts and showing the nesting levels.

As always, have a look at the changelog for an overview of all changes.

HexaPDF 0.34.0 - Optional Content aka Layers Published on

The highlight of this release is the support for optional content aka layers.

Optional content allows one to selectively show or hide content. It is most often used to provide something akin to layers, think a building plan with separate layers for the walls, electrical infrastructure, furniture and so on. However, it can also be used for something more mundane, like hiding the answers of a quiz.

Apart from this larger change there is a new style property HexaPDF::Layout::Style#fill_horizontal which allows a text fragment to fill the remaining space of a line. This is very useful when creating table of content entries.

There is new documentation for the optional content feature and the document creation section got a new how-tos section which will be expanded in the future.

As always, have a look at the changelog for an overview of all changes.

HexaPDF 0.33.0 - Table Support Published on

This release contains many different changes and fixes. The highlight, however, is the support for tables.

Table Implementation

The biggest change in this release is the addition of HexaPDF::Layout::TableBox which allows the creation of fixed width tables:

Table box example

With this addition creating a table becomes very easy:

require 'hexapdf'

HexaPDF::Composer.create('table.pdf') do |composer|
  composer.table([['This', 'is'], ['a', 'table']], column_widths: [100, 100])

The table implementation supports

  • one or more boxes of any type inside a table cell,
  • header and footer rows,
  • column and row spans, as well as
  • easy styling of the whole table, rows, columns or individual cells.

There is also a new table benchmark which shows that HexaPDF is outperforming Prawn with the prawn-table gem.

Website Overhaul

The website got an overhaul and looks a bit (just a bit) different now. The changes were made to make the website feel more coherent in terms of styling and colors. Here are before and after images where this can be seen:

Image of API before change Image of API now

The documentation pages have also been enhanced with more sample PDFs. While the former version had 183 PDFs created with HexaPDF during the website generation, the current version has 237, so about 30% more!

Other Notable Changes

There was a bit of work making HexaPDF faster and use less memory. This can be seen in the line wrapping benchmark where the low-level version and the HexaPDF::Composer version are now nearly on par. Another change reduced the number of Fiber instances which greatly improves HexaPDF performance on TruffleRuby.

The API documentation of many classes has also been updated and enhanced. This is an ongoing process which will see all API documentation being updated.

As always, have a look at the changelog for an overview of all changes.