Page 1 of 1

GDocx: fluent interface to Docx4j

PostPosted: Thu Jun 27, 2013 1:15 am
by Gualtiero
As a small contribution to Docx4j project, I have open sourced a library I developed time ago for a project where I used Docx4j.

The library, named GDocx, add a fluent like interface on top of Docx4j.

Small example:
Code: Select all
GP p = GP.create().text("Tahoma 24 red right aligned").font("Tahoma", 24).color("FF0000").align(JcEnumeration.CENTER);

The above line creates a paragraph with Tahoma 24, red color, center aligned. The p instance can be used everywhere a Docx4j's P instance can be used.

Similar approach for table, row and cells. Please note that not all Docx4j API has a fluent counterpart in GDocx.

The GDocx library is released under Apache 2.0 License and it can be downloaded from https://java.net/projects/gdocx

Comments and requests can be added on the project area.

Re: GDocx: fluent interface to Docx4j

PostPosted: Sat Jul 06, 2013 11:51 am
by jason
Nice work! :-) I've linked to your project home from http://www.docx4java.org/trac/docx4j/wiki/WikiStart

At one point I pondered using https://java.net/projects/jaxb2-commons ... Fluent-api to add a fluent API at the JAXB level, but never got around to it...

I see from https://java.net/projects/gdocx/sources ... esta/gdocx that you've taken a different approach, which has the potential to be matched more closely with the most common use cases. Good stuff!