This is a (very) small project that builds upon Apache's PDFBox (>= 2.0.0) 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)
- row spanning
- line breaking and line spacing
- images in cells
In order to produce a whole PDF document with a table that looks like this one:
You will need this code.
There are more examples (just see the folder), for instance this one:
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.
First check it out and install it locally:
git clone https://github.com/vandeseer/easytable.git
cd easytable
git checkout v0.2.1
mvn clean install
Define this in your pom.xml
in order to use it:
<dependency>
<groupId>org.vandeseer.pdfbox</groupId>
<artifactId>easytable</artifactId>
<version>0.2.1</version>
</dependency>
At one point it will hopefully also be available at maven central.
- to Binghammer for implementing cell coloring and text center alignment
- to Sebastian Göhring for finding and fixing a bug (column spanning)
- to AndreKoepke for the line breaking feature, some bigger nice refactorings and improvements
- to Wolfgang Apolinarski for the printing over pages and bugfixes
Nope. You will need Java 8.
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 ...
Yes. Or you can upvote this answer on stackoverflow.