class PDF extends java.lang.Object
A light weight PDF Builder for creating PDFs to show results.
To create a PDF, instantiate a PDF object and use the document(String, Closure) method to initiate the building of a PDF document.
Example:
new PDF().document("test.pdf") { title("This is My PDF") br() p("This is a PDF document") color("RED") { bold { p("This paragraph is red and bold") } } table { head { cells("Name","Age","Height") } cells("Simon", 18, 168) color("BLUE") { cell("Peter") } // Peter will be blue! cells(28, 92) } // Note: the image will be autoscaled and centered img("test.jpg") }
Note: This implementation is based on iText, a PDF generation library that changed from MPL to LGPL then to AGPL. This implementation is compatible with the original MPL licensed version. Some people consider it unwise or unethical to use that version but this is obviously an individual judgement to be made.
Type | Name and description |
---|---|
com.lowagie.text.Font |
currentFont |
com.lowagie.text.pdf.PdfPTable |
currentTable |
java.util.List<com.lowagie.text.Element> |
elementStack |
java.util.List<Font> |
fontStack |
java.util.List<PdfPCell> |
headerCells |
java.util.List<Color> |
tableBackground |
java.util.List<java.util.Map> |
tableOpts |
Constructor and description |
---|
PDF
() |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
align(java.lang.String value, groovy.lang.Closure c) Set alignment within table cells |
|
void |
applyCellProperties(com.lowagie.text.pdf.PdfPCell cell) |
|
void |
background(java.lang.String color, groovy.lang.Closure c) Set background color of table cells |
|
void |
bg(java.lang.String color, groovy.lang.Closure c) |
|
void |
bold(groovy.lang.Closure c) |
|
void |
br(int number) |
|
void |
cell(java.lang.Object contents) |
|
void |
cells(java.lang.Iterable i) |
|
void |
cells(java.lang.Object[] values) |
|
void |
color(java.lang.String color, groovy.lang.Closure c) |
|
void |
document(java.io.File file, groovy.lang.Closure c) |
|
void |
document(java.lang.String fileName, groovy.lang.Closure c) |
|
void |
font(java.awt.Color color, int size, groovy.lang.Closure c) |
|
void |
fontSize(float size, groovy.lang.Closure c) |
|
void |
head(groovy.lang.Closure c) |
|
void |
img(java.lang.String src) |
|
void |
p(java.lang.String text) |
|
void |
red(groovy.lang.Closure c) |
|
void |
table(java.util.Map props, groovy.lang.Closure c) |
|
void |
table(groovy.lang.Closure c) |
|
void |
title(java.lang.Object contents) |
|
int |
toAlignment(java.lang.String value) |
|
java.awt.Color |
toColor(java.lang.String color) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Set alignment within table cells
Set background color of table cells
Groovy Documentation