use of com.itextpdf.layout.element.Cell in project i7js-highlevel by itext.
the class C05E02_ColumnWidths1 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Table table = new Table(new float[] { 200, 100, 100 });
table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")));
table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")));
table.addCell("row 1; cell 1");
table.addCell("row 1; cell 2");
table.addCell("row 2; cell 1");
table.addCell("row 2; cell 2");
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Cell in project i7js-highlevel by itext.
the class C05E02_ColumnWidths3 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Table table = new Table(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
table.setWidth(450);
table.setHorizontalAlignment(HorizontalAlignment.CENTER);
table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")));
table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")));
table.addCell("row 1; cell 1");
table.addCell("row 1; cell 2");
table.addCell("row 2; cell 1");
table.addCell("row 2; cell 2");
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Cell in project i7js-highlevel by itext.
the class C05E04_ColumnHeights method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Paragraph p = new Paragraph("The Strange Case of\nDr. Jekyll\nand\nMr. Hyde").setBorder(new DashedBorder(0.3f));
// Initialize document
Document document = new Document(pdf);
Table table = new Table(UnitValue.createPercentArray(new float[] { 1 }));
table.setWidth(UnitValue.createPercentValue(100));
table.addCell(p);
Cell cell = new Cell().setHeight(45).add(p);
table.addCell(cell);
cell = new Cell().setMinHeight(45).add(p);
table.addCell(cell);
cell = new Cell().setMinHeight(135).add(p);
table.addCell(cell);
cell = new Cell().setMaxHeight(45).add(p);
table.addCell(cell);
cell = new Cell().setMaxHeight(135).add(p);
table.addCell(cell);
cell = new Cell().add(p).setRotationAngle(Math.PI / 6);
table.addCell(cell);
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Cell in project i7js-highlevel by itext.
the class C05E09_JekyllHydeTableV2 method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf, PageSize.A4.rotate());
Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));
table.setWidth(UnitValue.createPercentValue(100));
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
List<String> header = resultSet.remove(0);
for (String field : header) {
table.addHeaderCell(field);
}
for (List<String> record : resultSet) {
for (String field : record) {
table.addCell(field);
}
}
Table outerTable = new Table(new float[] { 1 }).addHeaderCell("Continued from previous page:").setSkipFirstHeader(true).addCell(new Cell().add(table).setPadding(0));
document.add(outerTable);
document.close();
}
use of com.itextpdf.layout.element.Cell in project digilib by robcast.
the class PDFTitlePage method createPage.
/**
* Add the the title page to the PDF Document.
*
* @return
*/
public Document createPage(Document content) {
/*
* header with logo
*/
Table headerBlock = new Table(UnitValue.createPercentArray(new float[] { 20, 80 }));
Image logo = getLogo();
if (logo != null) {
logo.setWidth(UnitValue.createPercentValue(100));
headerBlock.addCell(new Cell().add(logo).setBorderRight(null));
}
String headerText = getHeaderTitle();
if (!headerText.isEmpty()) {
Cell textCell = new Cell().setBorderLeft(null).setPaddingLeft(12).add(new Paragraph(headerText).setBold());
String headerSubtext = getHeaderSubtitle();
if (headerSubtext != null) {
textCell.add(new Paragraph(headerSubtext));
}
headerBlock.addCell(textCell);
}
content.add(headerBlock.setMarginBottom(24));
String reference = getReference();
if (!reference.isEmpty()) {
/*
* full reference
*/
content.add(new Paragraph(reference));
} else {
/*
* author
*/
String author = getAuthor();
if (!author.isEmpty()) {
content.add(new Paragraph(author).setTextAlignment(TextAlignment.CENTER));
}
/*
* title
*/
String title = getTitle();
if (!title.isEmpty()) {
content.add(new Paragraph(title).setTextAlignment(TextAlignment.CENTER));
}
/*
* date
*/
String date = getDate();
if (!date.isEmpty()) {
content.add(new Paragraph(date).setTextAlignment(TextAlignment.CENTER));
}
}
/*
* page numbers
*/
content.add(new Paragraph(getPages()).setTextAlignment(TextAlignment.CENTER));
/*
* URL
*/
try {
content.add(new Paragraph().setTextAlignment(TextAlignment.CENTER).setFont(PdfFontFactory.createFont(StandardFonts.COURIER)).setFontSize(10).add(new Link(getUrl(), PdfAction.createURI(getUrl()))).setFixedPosition(24, 24, UnitValue.createPercentValue(98)));
} catch (IOException e) {
logger.error("{}", e);
}
return content;
}
Aggregations