drumonii / easytable

Small table drawing library building upon Apache PDFBox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

easytable

This is a (very) small project that builds upon Apache's PDFBox (>= 2.0.4) 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

Example

In order to produce a whole PDF document with a table that looks like this one:

easytable table

You will need this code. In the same file you find the code for this table:

easytable table

There are more examples (just see the folder), for instance this one:

easytable table

Again, just have a look at the code.

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.

Installation

Add this to your pom.xml:

<dependency>
    <groupId>com.github.vandeseer</groupId>
    <artifactId>easytable</artifactId>
    <version>0.4.0</version>
</dependency>

Kudos

Q&A

Does it work with Java < 8?

Nope. You will need 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 will have changed in the meantime ...

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

Yes. Or you can upvote this answer on stackoverflow.

About

Small table drawing library building upon Apache PDFBox

License:MIT License


Languages

Language:Java 100.0%