use of com.itextpdf.layout.element.Cell 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.Cell 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.Cell 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();
}
use of com.itextpdf.layout.element.Cell in project ComponentManagement by Bac3Phi.
the class ReportPaymentController method addTablePayments.
private void addTablePayments(Document document) throws SQLException {
float[] pointColumnWidths = { 200F, 200F, 200F };
Table table = new Table(pointColumnWidths);
table.addCell(new Cell().add("Mã Chi Tiết Chi").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
table.addCell(new Cell().add("Tên Mặt Hàng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
table.addCell(new Cell().add("Tổng Nhập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
resultSet = dbConn.getData("select MaCTC, TenMH, TongNhap\n" + "from CHITIETCHI CTC join MATHANG MH on CTC.MaMH = MH.MaMH\n" + "where MaBCTC = '" + txtPaymentReportId.getText() + "'");
while (resultSet.next()) {
table.addCell(new Cell().add(resultSet.getString("MaCTC")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
table.addCell(new Cell().add(resultSet.getString("TenMH")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
table.addCell(new Cell().add(String.valueOf(resultSet.getLong("TongNhap"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
}
document.add(table);
}
use of com.itextpdf.layout.element.Cell in project ComponentManagement by Bac3Phi.
the class ReportPaymentController method addTableRecetpts.
private void addTableRecetpts(Document document) throws SQLException {
float[] pointColumnWidths = { 200F, 200F, 200F };
Table table = new Table(pointColumnWidths);
table.addCell(new Cell().add("Mã Chi Tiết Thu").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
table.addCell(new Cell().add("Tên Mặt Hàng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
table.addCell(new Cell().add("Tổng Bán").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
resultSet = dbConn.getData("select MaCTT, TenMH, TongBan\n" + "from CHITIETTHU CTT join MATHANG MH on CTT.MaMH = MH.MaMH\n" + "where MaBCTC = '" + txtPaymentReportId.getText() + "'");
while (resultSet.next()) {
table.addCell(new Cell().add(resultSet.getString("MaCTT")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
table.addCell(new Cell().add(resultSet.getString("TenMH")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
table.addCell(new Cell().add(String.valueOf(resultSet.getLong("TongBan"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
}
document.add(table);
}
Aggregations