public void execute() {
try {
// step 1: creation of a document-object
Rectangle pageSize = new Rectangle(780, 525);
if (getValue("backgroundcolor") != null) pageSize.setBackgroundColor((Color)getValue("backgroundcolor"));
Document document = new Document(pageSize);
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
if (getValue("destfile") == null) throw new DocumentException("You must provide a destination file!");
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream((File)getValue("destfile")));
// step 3: we open the document
document.open();
// step 4:
PdfContentByte cb = writer.getDirectContent();
if (getValue("title") != null) {
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 24);
cb.beginText();
if (getValue("front") == null) {
cb.showTextAligned(Element.ALIGN_CENTER, (String)getValue("title"), 595f, 262f, 0f);
}
if (getValue("side") == null) {
cb.showTextAligned(Element.ALIGN_CENTER, (String)getValue("title"), 385f, 262f, 270f);
}
cb.endText();
}
cb.moveTo(370, 0);
cb.lineTo(370, 525);
cb.moveTo(410, 525);
cb.lineTo(410, 0);
cb.stroke();
if (getValue("front") != null) {
Image front = (Image)getValue("front");
front.scaleToFit(370, 525);
front.setAbsolutePosition(410f + (370f - front.scaledWidth()) / 2f, (525f - front.scaledHeight()) / 2f);
document.add(front);
}
if (getValue("back") != null) {
Image back = (Image)getValue("back");
back.scaleToFit(370, 525);
back.setAbsolutePosition((370f - back.scaledWidth()) / 2f, (525f - back.scaledHeight()) / 2f);
document.add(back);
}
if (getValue("side") != null) {
Image side = (Image)getValue("side");
side.scaleToFit(40, 525);
side.setAbsolutePosition(370 + (40f - side.scaledWidth()) / 2f, (525f - side.scaledHeight()) / 2f);
document.add(side);
}
// step 5: we close the document
document.close();
}
catch(Exception e) {
JOptionPane.showMessageDialog(internalFrame,
e.getMessage(),
e.getClass().getName(),