// get the stream content
PdfContentByte cb = writer.getDirectContent();
// headers
// Phrase fullTitle = new Phrase("Full Title", font24B);
float currentY = document.top();
ColumnText ct = new ColumnText(cb);
// ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, Element.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;
// for (int k = 1; k < numColumns; ++k) {
// float x = allColumns[k] - gutter / 2;
// cb.moveTo(x, topColumn);
// cb.lineTo(x, document.bottom());
// }
// cb.stroke();
//
Image img = Image.getInstance("c:\\lh.jpg");
cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
currentY -= img.getScaledHeight() + 10;
ct.setYLine(currentY);
// Chunk cc = new Chunk("DDD\n", font24B);
// ct.addText(cc);
Paragraph title1 = new Paragraph("Chapter 1", FontFactory.getFont(
FontFactory.HELVETICA, 18, Font.BOLDITALIC,
new Color(0, 0, 255)));
title1.setAlignment(Paragraph.ALIGN_CENTER);
ct.addElement(title1);
ct.go();
currentY = ct.getYLine();
currentY -= 4;
// PdfPTable ptable = new PdfPTable(2);
// ptable.getDefaultCell().setPaddingLeft(4);
// ptable.getDefaultCell().setPaddingTop(0);
// ptable.getDefaultCell().setPaddingBottom(4);
// ptable.addCell(new Phrase("Imprint Name:", font9));
// ptable.addCell(new Phrase("Prentice Hall", font9));
// ptable.addCell(new Phrase("Series Name:", font9));
// ptable.addCell(new Phrase("", font9));
// ptable.addCell(new Phrase("ISBN:", font9));
// ptable.addCell(new Phrase("Hall", font9));
// ptable.addCell(new Phrase("UPC Code:", font9));
// ptable.addCell(new Phrase("0789718103", font9));
// ptable.addCell(new Phrase("EAN #", font9));
// ptable.addCell(new Phrase("0786718103", font9));
// ptable.addCell(new Phrase("Price:", font9));
// ptable.addCell(new Phrase("49.99", font9));
// ptable.addCell(new Phrase("Page Count:", font9));
// ptable.addCell(new Phrase("500", font9));
// ptable.addCell(new Phrase("Discount:", font9));
// ptable.addCell(new Phrase("10%", font9));
// ptable.addCell(new Phrase("Trim Size:", font9));
// ptable.addCell(new Phrase("420x340", font9));
// ptable.addCell(new Phrase("Cover:", font9));
// ptable.addCell(new Phrase("Hard", font9));
// ptable.addCell(new Phrase("Interior Color:", font9));
// ptable.addCell(new Phrase("none", font9));
// ptable.addCell(new Phrase("Media with book:", font9));
// ptable.addCell(new Phrase("CD", font9));
// ptable.addCell(new Phrase("Author(s):", font9));
// ptable.addCell(new Phrase("Ben Forta", font9));
// ptable.addCell(new Phrase("Editor:", font9));
// ptable.addCell(new Phrase("Ben Forta", font9));
// ptable.addCell(new Phrase("Pub Date:", font9));
// ptable.addCell(new Phrase("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, Element.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, currentY, 15, Element.ALIGN_JUSTIFIED);
ct.setLeading(2, 1);
}
// step 5: we close the document
document.close();
}
catch (Exception de) {