List of usage examples for com.itextpdf.text.pdf PdfPTable setTotalWidth
public void setTotalWidth(final float columnWidth[]) throws DocumentException
From source file:cl.preguntame.clases.Cabecera.java
/** * Esta es el metodo a llamar cuando ocurra el evento onEndPage, es en este * evento donde crearemos el encabeazado de la pagina con los elementos * indicados.// w w w. ja v a 2s . c o m */ public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try { // Se determina el ancho y altura de la tabla table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); // Borde de la celda table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(encabezado); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Pagina % 01d de ", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); // Esta linea escribe la tabla como encabezado table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } catch (DocumentException de) { throw new ExceptionConverter(de); } }
From source file:cn.afterturn.easypoi.pdf.export.PdfExportServer.java
License:Apache License
public Document createPdfByExportEntity(PdfExportParams entity, List<ExcelExportEntity> excelParams, Collection<?> dataSet) { try {//from w ww . j a va 2s . c om sortAllParams(excelParams); for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) { if (excelParams.get(k).getList() != null) { isListData = true; break; } } //? float[] widths = getCellWidths(excelParams); PdfPTable table = new PdfPTable(widths.length); table.setTotalWidth(widths); //table.setLockedWidth(true); // createHeaderAndTitle(entity, table, excelParams); int rowHeight = getRowHeight(excelParams) / 50; Iterator<?> its = dataSet.iterator(); while (its.hasNext()) { Object t = its.next(); createCells(table, t, excelParams, rowHeight); } document.add(table); } catch (DocumentException e) { LOGGER.error(e.getMessage(), e); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } finally { document.close(); } return document; }
From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java
License:Apache License
/** * header ? footer //from w w w. jav a 2s . co m */ public void onEndPage(PdfWriter writer, Document document) { if (titleFlag) return; Font font = new Font(bfKorean, 9); PdfPTable hTable = new PdfPTable(1); PdfPTable ftable = new PdfPTable(3); try { hTable.setWidths(new int[] { 100 }); hTable.setTotalWidth(500); hTable.setLockedWidth(true); hTable.getDefaultCell().setFixedHeight(15); hTable.getDefaultCell().setBorder(Rectangle.BOTTOM); hTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); hTable.addCell(new Phrase(MessageUtil.getMessage("pdf.message.header.title"), font)); hTable.writeSelectedRows(0, -1, 50, 803, writer.getDirectContent()); ftable.setWidths(new int[] { 100, 100, 100 }); ftable.setTotalWidth(500); ftable.setLockedWidth(true); ftable.getDefaultCell().setBorder(Rectangle.TOP); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); ftable.addCell(new Phrase(MessageUtil.getMessage("pdf.message.footer.left"), font)); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); if (pagingFlag) ftable.addCell(new Phrase( MessageUtil.getMessage("pdf.message.footer.center", String.valueOf(writer.getPageNumber())), font)); else ftable.addCell(""); ftable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); ftable.addCell(new Phrase(String.valueOf(new SimpleDateFormat("yyyy/MM/dd").format(new Date())), font)); ftable.writeSelectedRows(0, -1, 50, 55, writer.getDirectContent()); } catch (Exception de) { throw new ExceptionConverter(de); } }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /*from ww w . j a va 2 s . c om*/ * Table * * @param section table? section ? * @param e table element * @throws Exception */ public static void setTable(Section section, Element e) throws Exception { int colSize = Integer.parseInt(e.getAttributeValue("size")); PdfPTable t = new PdfPTable(colSize); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); t.setSpacingAfter(12); t.getDefaultCell().setLeading(0.0F, 1.3F); t.getDefaultCell().setMinimumHeight(22); t.getDefaultCell().setPaddingBottom(8); t.getDefaultCell().setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); setTableHeader(e, t, colSize); setTableRow(e, t); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * //ww w .j ava2 s .c om * box * * @param section box section ? * @param e box element * @throws Exception */ public static void setBox(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBox)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBox)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(238, 236, 225)); t.addCell(cell); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * // w w w . jav a2 s .co m * box (Backgroud : Black) * * @param section box section ? * @param e box element * @throws Exception */ public static void setBoxB(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBoxWhite)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBoxWhite)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(0, 0, 0)); t.addCell(cell); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /* w w w .ja va2 s .co m*/ * box (Backgroud : White) * * @param section box section ? * @param e box element * @throws Exception */ public static void setBoxW(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBoxBlack)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBoxBlack)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(255, 255, 255)); t.addCell(cell); section.add(t); }
From source file:com.automaster.autoview.server.servlet.TableHeader.java
/** * Adds a header to every page/*from ww w. java2s . c o m*/ * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage( * com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document) */ public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try { table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(header); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Pgina %d de", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } catch (DocumentException de) { throw new ExceptionConverter(de); } }
From source file:com.cib.statementstamper.windows.StatementStamperMainWindow.java
License:Open Source License
protected PdfPTable getFooterTable(int x, int y) { PdfPTable table = new PdfPTable(1); table.setTotalWidth(537); table.setLockedWidth(true);/*from w ww . ja v a 2 s . c om*/ table.getDefaultCell().setFixedHeight(40); table.getDefaultCell().setBorder(Rectangle.TOP); table.getDefaultCell().setBorderColor(new BaseColor(221, 72, 20)); table.getDefaultCell().setBorderWidth(1); table.getDefaultCell().setPaddingLeft(0); table.getDefaultCell().setPaddingRight(0); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_JUSTIFIED); Phrase phrase = new Phrase(); phrase.add(new Chunk(bottomChunk1, bottomFontBold)); phrase.add(new Chunk(bottomChunk2, bottomFont)); table.addCell(phrase); return table; }
From source file:com.cib.statementstamper.windows.StatementStamperMainWindow.java
License:Open Source License
protected PdfPTable getIspLogoTable(int x, int y) { PdfPTable table = new PdfPTable(1); table.setTotalWidth(150); table.setLockedWidth(true);//from w ww . ja va 2 s.c o m table.getDefaultCell().setFixedHeight(40); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.addCell(isplogo); return table; }