use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E08_JekyllHydeTableV1 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);
}
Cell cell = new Cell(1, 6).add(new Paragraph("Continued on next page..."));
table.addFooterCell(cell).setSkipLastFooter(true);
for (List<String> record : resultSet) {
for (String field : record) {
table.addCell(field);
}
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E11_JekyllHydeTableV4 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)));
table.addCell(cell);
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class AlternatingBackgroundTableRenderer 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());
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
List<String> header = resultSet.remove(0);
Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));
table.setWidth(UnitValue.createPercentValue(100));
int nRows = resultSet.size();
table.setNextRenderer(new AlternatingBackgroundTableRenderer(table, new Table.RowRange(0, nRows - 1)));
for (String field : header) {
table.addHeaderCell(field);
}
for (List<String> record : resultSet) {
for (String field : record) {
table.addCell(field);
}
}
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class C05E15_LargeTable 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[] { 100, 100, 100 }, true);
table.addHeaderCell("Table header 1");
table.addHeaderCell("Table header 2");
table.addHeaderCell("Table header 3");
table.addFooterCell("Table footer 1");
table.addFooterCell("Table footer 2");
table.addFooterCell("Table footer 3");
document.add(table);
for (int i = 0; i < 1000; i++) {
table.addCell(String.format("Row %s; column 1", i + 1));
table.addCell(String.format("Row %s; column 2", i + 1));
table.addCell(String.format("Row %s; column 3", i + 1));
if (i % 50 == 0) {
table.flush();
}
}
table.complete();
document.close();
}
use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.
the class CellProperties 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(2)).useAllAvailableWidth();
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
table.addCell(new Cell().add(new Paragraph("Test 1")).setHeight(50).setDestination("Top"));
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW);
table.addCell(new Cell().setBorder(new DottedBorder(5)).add(new Paragraph("Test 2")).addStyle(style).setRelativePosition(10, 10, 50, 10));
table.addCell(new Cell().add(new Paragraph("Test 3")).setVerticalAlignment(VerticalAlignment.BOTTOM));
table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
table.addCell(new Cell().add(new Paragraph("Rotated")).setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
table.addCell(new Cell().add(new Paragraph("Centered")).setTextAlignment(TextAlignment.CENTER).setAction(PdfAction.createGoTo("Top")));
table.addCell(new Cell().add(new Paragraph("Test 5")).setBackgroundColor(ColorConstants.BLUE));
table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setPaddingLeft(20).setPaddingRight(50));
table.addCell(new Cell().add(new Paragraph("Test 7")).setBackgroundColor(ColorConstants.RED));
table.addCell(new Cell().add(new Paragraph("Test 8")).setBackgroundColor(ColorConstants.BLUE).setMarginBottom(10));
table.addCell(new Cell().add(new Paragraph("Test 9")).setBackgroundColor(ColorConstants.BLUE));
table.addCell(new Cell().add(new Paragraph("Test 10")).setBackgroundColor(ColorConstants.RED));
table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setMargin(50).setPadding(30));
table.addCell(new Cell().add(new Paragraph("Test 12")).setBackgroundColor(ColorConstants.BLUE));
document.add(table);
SolidBorder border = new SolidBorder(ColorConstants.RED, 2);
Cell cell = new Cell().add(new Paragraph("Test")).setFixedPosition(100, 400, 350).setBorder(border).setBackgroundColor(ColorConstants.BLUE).setHeight(100).setHorizontalAlignment(HorizontalAlignment.CENTER);
document.add(cell);
document.close();
}
Aggregations