use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E12_JekyllHydeTableV5 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, PageSize.A4.rotate());
Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 32 }));
table.setWidth(UnitValue.createPercentValue(100));
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
resultSet.remove(0);
table.addHeaderCell("imdb").addHeaderCell("Information about the movie");
Cell cell;
for (List<String> record : resultSet) {
table.addCell(record.get(0));
cell = new Cell().add(new Paragraph(record.get(1))).add(new Paragraph(record.get(2))).add(new Paragraph(record.get(3))).add(new Paragraph(record.get(4))).add(new Paragraph(record.get(5)));
cell.setKeepTogether(true);
table.addCell(cell);
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E14_JekyllHydeTableV7 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, 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) {
table.addCell(record.get(0));
table.addCell(record.get(1));
Cell cell = new Cell().add(new Paragraph(record.get(2)));
cell.setNextRenderer(new RunlengthRenderer(cell, record.get(5)));
table.addCell(cell);
table.addCell(record.get(3));
table.addCell(record.get(4));
table.addCell(record.get(5));
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E10_JekyllHydeTableV3 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, PageSize.A4.rotate());
Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
List<String> header = resultSet.remove(0);
for (String field : header) {
table.addHeaderCell(field);
}
Cell cell;
for (List<String> record : resultSet) {
cell = new Cell();
File file = new File(String.format("src/main/resources/img/%s.jpg", record.get(0)));
if (file.exists()) {
Image img = new Image(ImageDataFactory.create(file.getPath()));
img.setAutoScaleWidth(true);
img.setWidth(UnitValue.createPercentValue(100));
cell.add(img);
} else {
cell.add(new Paragraph(record.get(0)));
}
table.addCell(cell);
table.addCell(record.get(1));
table.addCell(record.get(2));
table.addCell(record.get(3));
table.addCell(record.get(4));
table.addCell(record.get(5));
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E01_MyFirstTable 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[] { 1, 1, 1 });
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.Table in project i7js-highlevel by itext.
the class C05E02_ColumnWidths4 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(UnitValue.createPercentValue(80));
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();
}
Aggregations