pageSize.getWidth() - 110,
pageSize.getHeight() - 250
);
blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
StandardType1Font titleFont = new StandardType1Font(
document,
StandardType1Font.FamilyEnum.Times,
true,
false
);
composer.setFont(titleFont,48);
blockComposer.showText("Welcome"); blockComposer.showBreak();
StandardType1Font bodyFont = new StandardType1Font(
document,
StandardType1Font.FamilyEnum.Times,
false,
false
);
composer.setFont(bodyFont,16);
blockComposer.showText("This is an on-the-fly servlet-driven PDF sample document generated by PDF Clown for Java.");
blockComposer.end();
// Move past the closed block!
frame.y = blockComposer.getBoundBox().getMaxY() + 30;
frame.height -= (blockComposer.getBoundBox().getHeight() + 30);
// Showing the posted image...
// Instantiate a jpeg image object!
Image image = null;
try
{
image = Image.get(
new Buffer(imageFileFormField.get())
); // Abstract image (entity).
}
catch(Exception e)
{/* NOOP. */}
if(image == null)
{
blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
composer.setFont(bodyFont,12);
composer.setFillColor(new DeviceRGBColor(1,0,0));
blockComposer.showText("The file you uploaded wasn't a valid JPEG image!");
blockComposer.end();
// Move past the closed block!
frame.y = blockComposer.getBoundBox().getMaxY() + 20;
frame.height -= (blockComposer.getBoundBox().getHeight() + 20);
}
else
{
blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
composer.setFont(bodyFont,12);
blockComposer.showText("Here it is the image you uploaded: ");
blockComposer.end();
// Move past the closed block!
frame.y = blockComposer.getBoundBox().getMaxY() + 20;
frame.height -= (blockComposer.getBoundBox().getHeight() + 20);
double width = image.getWidth(), height = image.getHeight();
if(width > frame.getWidth())
{
height *= frame.getWidth() / width;
width = frame.getWidth();
}
if(height > frame.getHeight() / 2)
{
width *= frame.getHeight() / 2 / height;
height = frame.getHeight() / 2;
}
// Show the image!
composer.showXObject(
image.toXObject(document),
new Point2D.Double(
(pageSize.getWidth() - 90 - width) / 2 + 20,
blockComposer.getBoundBox().getMaxY() + 20
),
new Dimension(width,height)
);
// Move past the image closed block!
frame.x = (pageSize.getWidth() - 90 - width) / 2 + 20;
frame.y += (height + 7);
frame.height -= (height + 7);
frame.width = width;
}
if (comment != null)
{
blockComposer.begin(frame,AlignmentXEnum.Justify,AlignmentYEnum.Top);
composer.setFont(
new StandardType1Font(
document,
StandardType1Font.FamilyEnum.Courier,
false,
false
),