{
// 1. Add the page to the document!
Page page = new Page(document); // Instantiates the page inside the document context.
document.getPages().add(page); // Puts the page in the pages collection.
Dimension2D pageSize = page.getSize();
// 2. Create a content composer for the page!
PrimitiveComposer composer = new PrimitiveComposer(page);
// 3. Drawing the page contents...
try
{
composer.setFont(
new StandardType1Font(
document,
StandardType1Font.FamilyEnum.Courier,
true,
false
),
32
);
}
catch(Exception e)
{throw new RuntimeException(e);}
EnumSet<AlignmentXEnum> xAlignments = EnumSet.allOf(AlignmentXEnum.class);
EnumSet<AlignmentYEnum> yAlignments = EnumSet.allOf(AlignmentYEnum.class);
int step = (int)(pageSize.getHeight()) / (xAlignments.size() * yAlignments.size()+1);
BlockComposer blockComposer = new BlockComposer(composer);
{
blockComposer.begin(
new Rectangle2D.Double(
30,
0,
pageSize.getWidth()-60,
step*.8
),
AlignmentXEnum.Center,
AlignmentYEnum.Middle
);