Totally Tubular Tabular Tools for Document Generation

Earlier this month the Adobe Acrobat Services team released a set of improvements to our Document Generation API. These updates are all related to table support and in this post, we’ll share some examples of what’s now possible.
Tables via HTML
As you (hopefully) know, when passing data to the Document Generation API, you can use a subset of supported HTML tags within your data. So for example:
When the bio
tag is replaced in your Word document, the value will include text has the bold style applied. Developers can make use of span
, br
, b
, strong
, em
, i
, u
, and p
, as well as basic inline style declarations:
You can read more details about this support in our docs, but as of the most recent release, you can now use the table
tag as well. Let's consider an example. First, an HTML table with three rows:
You’ll notice the top row is using th
tags for a header. And here's our sample Word document:

When sent to the API, we get this result in our PDF:

You’ll notice no borders around the cells which matches default behavior on the web as well. Here we’ve added a border and spacing to the table via inline attributes:
And the result:

One important caveat is that your tabular data should be in a paragraph by itself, as shown in the earlier Word screen shot. The example below will not work:

Dynamically hiding table rows
Document Generation previously supported dynamically hiding table columns, but this release now adds support to rows as well.
Unlike column support, this feature adds a conditional check to a particular cell. You can choose to add conditions to multiple cells, and if any of the conditions evaluates to true, the entire row is hidden. Let’s imagine a set of data consisting of, oh, I don’t know, how about cats?
Let’s begin by adding this to our Word document as is. Here we’ve done so with no additional formatting or logic.

And here’s the resulting PDF:

Now let’s apply a bit of logic to our rows. First, we want to hide any row for a male cat. To do this we’re going to modify the gender
cell like so:
The basic syntax is to provide an expression first (the expr
portion), and then the context second (the array, cats
). Here it is modified in the Word document:

And the result:

Next, we’ll make our logic a bit more complex. Along with hiding the males we also want to hide any cats with an age less than 10. We can do that by adding the logic to the age
column like so:
Together now, both conditions will be run and if any evaluate to true, the entire row is hidden. Here’s how the PDF looks now:

Conditions in table cells
For the final update, we’ll cover new support for conditions within table cells. While conditions have worked outside of tables since the initial release of the Document Generation API, conditions within table cells were not possible via template tags. (As with most things in Document Generation, when something isn’t possible via tags in the template, it almost always can be handled by preprocessing your data before sending it to the API.)
As with the previous feature, the syntax is slightly different from what you would use outside of tables. Specifically with the addition of eval
at the end of the tag. Here's an example of how this looks:
In the sample above, the list or array of data, arrayData
, needs to be included in the expression at the end. It's a bit wordy, but this helps the API understand that we're checking a particular array item value.
Given our list of cats above, here’s an example where different output is used based on age. When the age value is less than ten, the age is output as is. When it’s ten or higher, it’s bold and red.

And here’s the resulting PDF:

More information
We hope these updates let you build better and more powerful dynamic templates with the API, and as always, be sure to read the docs for more information. As always, find us on our support forums for help.