// get the stream content
PdfContentByte cb = writer.getDirectContent();
// headers
LwgPhrase fullTitle = new LwgPhrase("Full Title", font24B);
float currentY = document.top();
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, LwgElement.ALIGN_JUSTIFIED);
ct.go();
currentY = ct.getYLine();
currentY -= 4;
cb.setLineWidth(1);
cb.moveTo(document.left(), currentY);
cb.lineTo(document.right(), currentY);
cb.stroke();
currentY -= 4;
ct.setYLine(currentY);
ct.addText(new Chunk("Author: Name of the author comes here", font10B));
ct.setLeading(10);
ct.go();
currentY = ct.getYLine();
currentY -= 15;
float topColumn = currentY;
for (int k = 1; k < numColumns; ++k) {
float x = allColumns[k] - gutter / 2;
cb.moveTo(x, topColumn);
cb.lineTo(x, document.bottom());
}
cb.stroke();
LwgImage img = LwgImage.getInstance("cover.png");
cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
currentY -= img.getScaledHeight() + 10;
ct.setYLine(currentY);
ct.addText(new Chunk("Key Data:", font14B));
ct.go();
currentY = ct.getYLine();
currentY -= 4;
LwgPdfPTable ptable = new LwgPdfPTable(2);
ptable.getDefaultCell().setPaddingLeft(4);
ptable.getDefaultCell().setPaddingTop(0);
ptable.getDefaultCell().setPaddingBottom(4);
ptable.add(new LwgPhrase("Imprint Name:", font9));
ptable.add(new LwgPhrase("Prentice Hall", font9));
ptable.add(new LwgPhrase("Series Name:", font9));
ptable.add(new LwgPhrase("", font9));
ptable.add(new LwgPhrase("ISBN:", font9));
ptable.add(new LwgPhrase("Hall", font9));
ptable.add(new LwgPhrase("UPC Code:", font9));
ptable.add(new LwgPhrase("0789718103", font9));
ptable.add(new LwgPhrase("EAN #", font9));
ptable.add(new LwgPhrase("0786718103", font9));
ptable.add(new LwgPhrase("Price:", font9));
ptable.add(new LwgPhrase("49.99", font9));
ptable.add(new LwgPhrase("Page Count:", font9));
ptable.add(new LwgPhrase("500", font9));
ptable.add(new LwgPhrase("Discount:", font9));
ptable.add(new LwgPhrase("10%", font9));
ptable.add(new LwgPhrase("Trim Size:", font9));
ptable.add(new LwgPhrase("420x340", font9));
ptable.add(new LwgPhrase("Cover:", font9));
ptable.add(new LwgPhrase("Hard", font9));
ptable.add(new LwgPhrase("Interior Color:", font9));
ptable.add(new LwgPhrase("none", font9));
ptable.add(new LwgPhrase("Media with book:", font9));
ptable.add(new LwgPhrase("CD", font9));
ptable.add(new LwgPhrase("Author(s):", font9));
ptable.add(new LwgPhrase("Ben Forta", font9));
ptable.add(new LwgPhrase("Editor:", font9));
ptable.add(new LwgPhrase("Ben Forta", font9));
ptable.add(new LwgPhrase("Pub Date:", font9));
ptable.add(new LwgPhrase("06/05/1998", font9));
ptable.setTotalWidth(columnWidth);
currentY = ptable.writeSelectedRows(0, -1, document.left(), currentY, cb) - 20;
for (int k = 0; k < headings.length; ++k) {
ct.addText(new Chunk(headings[k] + "\n", font14B));
ct.addText(new Chunk(texts[k] + "\n\n", font11));
}
int currentColumn = 0;
ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
allColumns[currentColumn] + columnWidth, currentY, 15, LwgElement.ALIGN_JUSTIFIED);
ct.setLeading(2, 1);
for (;;) {
int rc = ct.go();
if ((rc & ColumnText.NO_MORE_TEXT) != 0)
break;
// we run out of column. Let's go to another one
++currentColumn;
if (currentColumn >= allColumns.length)
break;
ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
allColumns[currentColumn] + columnWidth, topColumn, 15, LwgElement.ALIGN_JUSTIFIED);
ct.setLeading(2, 1);
}
// step 5: we close the document
document.close();
}
catch (Exception de) {