Skip to content
Small table drawing library built upon Apache PDFBox
Branch: master
Clone or download
Stefan Deser
Latest commit d7b4249 Dec 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Updated README Dec 15, 2019
src Removed obsolete code Dec 15, 2019
.gitignore ISSUE-4 font per cell Oct 2, 2018
LICENSE Added a LICENSE file (MIT) Jun 20, 2017 Update README Dec 15, 2019
pom.xml Increased version to 0.6.0 Dec 15, 2019


This is a (very) small project that builds upon Apache's PDFBox and should allow you to create tables in a fairly simple way. It emerged from the need in another project. Therefore it also may miss some crucial features. Nevertheless there is:

  • setting font and font size on table, row and cell level
  • setting single cells with bottom-, top-, left- and right-border width separately
  • background color on table, row and cell level
  • padding (top, bottom, left, right) on cell level
  • border colors (on table, row or cell level)
  • support for text alignment (right, left, center, justified)
  • vertical text alignment (top, middle, bottom)
  • cell spanning and row spanning
  • line breaking and line spacing
  • images in cells
  • experimental: vertical text, links and paragraphs within cells

One can also override classes that are responsible for table/cell drawing, i.e. their drawing behaviour can be customized to a pretty high extent.

It is also possible to draw a table over multiple pages (even with the header row being repeated on every new page).


Add this to your pom.xml:


Or checkout the repository and install it locally with maven (e.g. for thedevelop branch):

mvn install -DskipTests -Dgpg.skip


There is a minimal full working example which should help you getting started.

For a bit more involved tables have a look at this code which is needed for creating a PDF document with the following two tables:

easytable table

easytable table

For the next example have a look at the

easytable table

The last one illustrates the use of vertical text in text cells. The code for it can be found here:

easytable table

If you run the tests with mvn clean test there also some PDF documents created which you can find in the target folder. The corresponding sources (in order to understand how to use the code) can be found in the test package.

Paragraph Cells

Since several people asked me to include a way to add hyperlinks within cells I did a bit of research and stumbled across a really nice library named pdfbox-layout. Unfortunately that library will not be developed any further, but it still provides a very powerful API for creating paragraphs with "styled text" (including links as well as markup).

Therefore I created a wrapper cell type (named ParagraphCell) which allows to append

  • hyperlinks
  • styled text (i.e. colorable text with a font and font size) as well as
  • markup (please see this documentation).

Note that the easytable API may be a bit different to what you find in the linked documentation. Anyway, in order to get your hands dirty look at this code on how to create such a table:

table with markup

Adding Needed Dependency

This is still a bit experimental and there may be changes in the future. If you want to use this feature nevertheless you need to add pdfbox-layout as a dependency. In case you are using maven for instance in your pom.xml:


Enable Links

Please note that you also need to set the page(...) on the TableDrawer you are using in case you want to add hyperlinks! Otherwise you will get a NullPointerException. For instance:

    .page(page) // <-- This is needed for links to work!



Can I customize the drawers for my own specific needs?

Yep, you can customize the cell drawers itself or (depending on your use case) you can just create a custom cell.

For using a customized cell drawer, have a look at CustomCellDrawer.

In case you want to create your own type of cell (which shouldn't really be necessary since the drawing can be completely adapted) you will need to use Lombok's @SuperBuilder annotation. Again, just have a look at the code: CustomCellWithCustomDrawerUsingLombok

Can I draw a table over multiple pages?

Yes, have a look at Just use startY(...) and endY(..) in order to restrict the vertical part of the page where the table should be drawn:

    .endY(50F) // <-- If the table is bigger, a new page is started

Does it work with Java < 8?

Nope. You will need at least Java 8.

Does it work with PDFBox 1.8.9?

Well, Using it with PDFBox 1.8.9 requires you to check out version 0.0.7 (tagged as such in git) and install it locally, i.e.:

git checkout v0.0.7
mvn clean install

Note though that the API has changed quite a bit in the meantime ...

Cool, I like it, can I buy you a beer?

Yes. Or you can upvote this answer on stackoverflow.

You can’t perform that action at this time.