List of usage examples for com.itextpdf.text.pdf PdfPTable writeSelectedRows
public float writeSelectedRows(final int rowStart, final int rowEnd, final float xPos, final float yPos, final PdfContentByte canvas)
From source file:de.aidger.utils.pdf.ActivityReportConverter.java
License:Open Source License
/** * Creates the table of employments./*from w w w. j ava 2 s . c o m*/ */ private void createTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10); String[] tableTitles = { "Zeitraum", "Veranstaltung", "Umfang" }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(new float[] { 0.2f, 0.6f, 0.2f }); /* * Create the titles of the table entries. */ for (int i = 0; i < tableTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(tableTitles[i], tableTitleFont)); titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setPaddingBottom(2.0f); cell.setBorder(0); contentTable.addCell(cell); cell = new PdfPCell(addRows()); cell.setBorder(0); contentTable.addCell(cell); float xPos = 60, yPos = 500, width = reader.getPageSize(1).getWidth() - 120f; if (form.getFieldPositions("TableField") != null) { FieldPosition position = form.getFieldPositions("TableField").get(0); xPos = position.position.getLeft(); yPos = position.position.getTop(); width = position.position.getWidth(); } contentTable.setTotalWidth(width); contentTable.writeSelectedRows(0, -1, xPos, yPos, contentByte); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.beimax.talenttree.PageGeneratorSimple.java
License:Open Source License
/** * Add single talent in box// ww w .j av a 2s.co m * @param row row to print talent in * @param col column to print talent in * @param key key for talent information * @param multiCols span multiple columns or 1 * @param customCost custom cost of talent (instead of default) - 0 means box will not be printed */ protected void addTalent(int row, int col, String key, int multiCols, int customCost) throws Exception { // get data HeaderProperties headerProperties = parseHeaderProperty(key); // define color BaseColor bgColor = headerProperties.active ? PDFGenerator.activeColor : PDFGenerator.passiveColor; boolean headerTwoLine = headerProperties.title.contains("\n"); // calculate offsets float x = calculateColOffset(col); float y = calculateRowOffset(row); // sanity check for multiple columns if (multiCols < 1) multiCols = 1; else if (multiCols > 4) multiCols = 4; // box width and height float talentBoxWidth = PDFGenerator.talentBoxWidth * multiCols + calculateHorizontalSpacing() * (multiCols - 1); float talentBoxHeight = PDFGenerator.talentBoxHeight; // draw shapes canvas.saveState(); // draw outer rectangle drawTalentRectangle(bgColor, x, y, talentBoxWidth, talentBoxHeight); // draw left footer shape float yFooterBoxOffset = y - talentBoxHeight + PDFGenerator.talentBoxStroke; if (customCost != 0) { drawFooterShape(bgColor, x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke, y - talentBoxHeight + PDFGenerator.talentBoxStroke, 25); } // draw right footer shape drawFooterShape(bgColor, x + talentBoxWidth - PDFGenerator.wedgeOffset - PDFGenerator.talentBoxStroke - 50, y - talentBoxHeight + PDFGenerator.talentBoxStroke, 50); // draw header shape drawHeaderShape(bgColor, x + PDFGenerator.talentBoxStroke * 2.5f, y - PDFGenerator.talentBoxStroke * 2.5f, talentBoxWidth - PDFGenerator.talentBoxStroke * 5, headerTwoLine, headerProperties.status); canvas.restoreState(); // draw text canvas.beginText(); canvas.setColorFill(BaseColor.WHITE); // title canvas.setFontAndSize(generator.getFontHeader(), 13); float offSetYTalentText; if (headerTwoLine) { String[] parts = headerProperties.title.split("\\n"); canvas.showTextAligned(Element.ALIGN_LEFT, parts[0], x + PDFGenerator.talentBoxStroke * 3.5f, y - PDFGenerator.talentBoxStroke * 2 - 14f, 0); canvas.showTextAligned(Element.ALIGN_LEFT, parts[1], x + PDFGenerator.talentBoxStroke * 3.5f, y - PDFGenerator.talentBoxStroke * 2 - 27f, 0); offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 28f; } else { canvas.showTextAligned(Element.ALIGN_LEFT, headerProperties.title, x + PDFGenerator.talentBoxStroke * 3.5f, y - PDFGenerator.talentBoxStroke * 2 - 14f, 0); offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 15f; } // mini text canvas.setFontAndSize(generator.getFontBold(), 6.25f); float textOffsetY = yFooterBoxOffset + 8 - 6.25f / 2 + 0.5f; // draw page canvas.showTextAligned(Element.ALIGN_CENTER, headerProperties.page, x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke + 25f / 2, textOffsetY, 0); // draw costs if (customCost != 0) { if (customCost == -1) customCost = (row + 1) * 5; canvas.showTextAligned(Element.ALIGN_LEFT, getLocalizedString("Cost") + " " + customCost, x + talentBoxWidth - PDFGenerator.talentBoxStroke - 50, textOffsetY, 0); } canvas.endText(); // draw talent text canvas.setColorFill(BaseColor.BLACK); PdfPTable table = getTalentCell(key, talentBoxWidth, 9f); // too large? float max = y - talentBoxHeight; if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset) table = getTalentCell(key, talentBoxWidth, 8.5f); // create smaller cell if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset) table = getTalentCell(key, talentBoxWidth, 7.5f); // create tiny cell table.writeSelectedRows(0, -1, x + PDFGenerator.talentBoxStroke * 1.5f, offSetYTalentText, canvas); }
From source file:Export.DocOfReCoSeguro.java
public static void docSeguros(String nomeSeguro, String user, String arquivo, String numDebito, String tileDoc, int idReseguro, boolean isReseguroOfNICON) { String reString;//from ww w . jav a 2s . c o m try { Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f); Font fontLinha = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f); Font fontCabecalhoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f, Font.UNDERLINE); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontNull = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f); Font fontMenor = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f); DataResseguro reS = DataReseguro.getDadosReseguro(idReseguro); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 }); pTableEmpresaPricipal.setWidthPercentage(90); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 }); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoN)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellCapital = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAPITALSOCIAL, fontCabecalhoN)); pCellCapital.setBorder(0); PdfPCell pCellPolice = new PdfPCell( new Phrase(ConfigDoc.Empresa.APOLICE + reS.getAPOLICE(), fontCabecalhoN)); pCellPolice.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 100f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); pTableEmpresaInforImpres2.addCell(pCellCapital); pTableEmpresaInforImpres2.addCell(pCellPolice); PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2); cellTabela1.setBorder(0); pTableEmpresaInforImpres4.addCell(cellTabela1); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4); cellTabela4.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela4); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); pTableEmpresaPricipal.addCell(cellTabela5); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT); pTableEmpresaPricipal.addCell(cellTabela6); PdfPTable pTableLinha = new PdfPTable(1); pTableLinha.setWidthPercentage(90); PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha)); linha.setBorderWidthTop(0.5f); linha.setBorderWidthBottom(0); linha.setBorderWidthLeft(0); linha.setBorderWidthRight(0); pTableLinha.addCell(linha); /** * Tile Doc start */ /* PdfPTable pTableTileDoc = new PdfPTable(new float[]{50, 50}); PdfPCell cellTileDoc = new PdfPCell(new Phrase(tileDoc, fontCabecalhoS)); cellTileDoc.setColspan(2); cellTileDoc.setPaddingTop(10f); cellTileDoc.setPaddingBottom(20f); cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellTileDoc.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellTileDoc); Paragraph pTile = new Paragraph(); pTile.add(new Phrase("DEBIT: ", fontCorpoN)); pTile.add(new Phrase("NiCON Seguros STP", fontCorpoN)); PdfPCell cellDebit = new PdfPCell(pTile); cellDebit.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellDebit); Paragraph pNotaNum = new Paragraph(); pNotaNum.add(new Phrase("DEBIT NOTE NO: ", fontCorpoN)); pNotaNum.add(new Phrase("05525", fontCorpo)); cellDebit = new PdfPCell(pNotaNum); cellDebit.setPaddingLeft(20f); cellDebit.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellDebit); cellDebit = new PdfPCell(new Phrase(" Avenida Marginal 12 de Junlho, 977", fontCorpo)); cellDebit.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellDebit); Paragraph pDate = new Paragraph(); pDate.add(new Phrase("Date: ", fontCorpoN)); SimpleDateFormat format = new SimpleDateFormat("dd MMMM',' yyyy",new Locale("pt", "BR")); pDate.add(new Phrase(format.format(new Date()), fontCorpo)); cellDebit = new PdfPCell(pDate); cellDebit.setBorder(PdfPCell.NO_BORDER); cellDebit.setPaddingLeft(20f); pTableTileDoc.addCell(cellDebit); cellDebit = new PdfPCell(new Phrase(" Cx Postal 556-So Tom", fontCorpo)); cellDebit.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellDebit); cellDebit = new PdfPCell(new Phrase(" ")); cellDebit.setBorder(PdfPCell.NO_BORDER); pTableTileDoc.addCell(cellDebit); */ /** * Tile Doc end */ ArrayList<DataEmpresa> listaDataEmpresas = DataReseguro.getDadosEmpresa(idReseguro); /** * Data Parte 1 Start */ PdfPTable pTableDataPart1 = new PdfPTable(new float[] { 18f, 82f }); pTableDataPart1.setWidthPercentage(90); PdfPCell cellDataPart1 = new PdfPCell(new Phrase("EMPRESA LIDER:", fontCorpoN)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(10f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell( new Phrase(((!isReseguroOfNICON) ? listaDataEmpresas.get(0).getEMPRESA().toUpperCase() : ConfigDoc.Empresa.NOME), fontCorpo)); cellDataPart1.setPaddingTop(10f); cellDataPart1.setPaddingBottom(5f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase("CONTRATO N:", fontCorpoN)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase(reS.getAPOLICE(), fontCorpo)); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase("DESCRIO:", fontCorpoN)); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase(reS.getDESCRICAO(), fontCorpo)); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase("PERIODO:", fontCorpoN)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase(reS.getINICIO() + " - " + reS.getFIM(), fontCorpo)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase("LIMITE:", fontCorpoN)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase((covertDouble(reS.getLIMITE()) == null) ? reS.getLIMITE() : Moeda.format(covertDouble(reS.getLIMITE())), fontCorpo)); cellDataPart1.setBorder(PdfPCell.NO_BORDER); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(5f); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase("MOEDA:", fontCorpoN)); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(10f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); cellDataPart1 = new PdfPCell(new Phrase(reS.getMOEDA(), fontCorpo)); cellDataPart1.setPaddingTop(5f); cellDataPart1.setPaddingBottom(10f); cellDataPart1.setBorder(PdfPCell.NO_BORDER); pTableDataPart1.addCell(cellDataPart1); /** * Data Part 1 end */ /** * Data Part 2 start */ PdfPTable pTableDataPart2 = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f }); pTableDataPart2.setWidthPercentage(90); PdfPCell cellDataPart2 = new PdfPCell(new Phrase("PREMIO GROSSO:", fontCorpoN)); cellDataPart2.setColspan(2); cellDataPart2.setBorder(PdfPCell.NO_BORDER); cellDataPart2.setPaddingTop(10f); cellDataPart2.setPaddingBottom(5f); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(), fontCorpo)); cellDataPart2.setPaddingTop(10f); cellDataPart2.setPaddingBottom(5f); cellDataPart2.setBorder(PdfPCell.NO_BORDER); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase("DEDUO:", fontCorpoN)); cellDataPart2.setBorder(PdfPCell.NO_BORDER); cellDataPart2.setColspan(2); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(5f); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase(reS.getDEDUCAO() + "%", fontCorpo)); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(5f); cellDataPart2.setBorder(PdfPCell.NO_BORDER); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase("LIQUIDO:", fontCorpoN)); cellDataPart2.setBorder(PdfPCell.NO_BORDER); cellDataPart2.setColspan(2); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(5f); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(), fontCorpo)); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(5f); cellDataPart2.setBorder(PdfPCell.NO_BORDER); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase("TOTAL:", fontCorpoN)); cellDataPart2.setBorder(PdfPCell.NO_BORDER); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(10f); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase("100%", fontCorpo)); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(10f); cellDataPart2.setBorder(PdfPCell.NO_BORDER); pTableDataPart2.addCell(cellDataPart2); cellDataPart2 = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(reS.getTOTAL().replace(',', '.'))) + " " + reS.getMOEDA(), fontCorpo)); cellDataPart2.setPaddingTop(5f); cellDataPart2.setPaddingBottom(10f); cellDataPart2.setBorder(PdfPCell.NO_BORDER); pTableDataPart2.addCell(cellDataPart2); // cellDataPart2 = new PdfPCell(new Phrase("Your faithfully", fontCorpo)); // cellDataPart2.setColspan(3); // cellDataPart2.setPaddingTop(5f); // cellDataPart2.setPaddingBottom(0.7f); // cellDataPart2.setBorder(PdfPCell.NO_BORDER); // pTableDataPart2.addCell(cellDataPart2); // cellDataPart2 = new PdfPCell(new Phrase("THE UNITED AFRICAN INSURANCE BROKERS LTD", fontCorpo)); // cellDataPart2.setColspan(3); // cellDataPart2.setPaddingTop(0.7f); // cellDataPart2.setPaddingBottom(10F); // cellDataPart2.setBorder(PdfPCell.NO_BORDER); // pTableDataPart2.addCell(cellDataPart2); /** * Data Part 2 end */ PdfPTable pTableSecureter = new PdfPTable(new float[] { 30f, 30f, 40f }); PdfPCell cellSecureterNull = new PdfPCell(new Phrase(" ", fontCorpoN)); cellSecureterNull.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellSecureterNull.setPaddingTop(2f); cellSecureterNull.setPaddingBottom(2f); cellSecureterNull.setColspan(3); cellSecureterNull.setBorder(PdfPCell.NO_BORDER); pTableSecureter.addCell(cellSecureterNull); cellSecureterNull.setColspan(0); if (isReseguroOfNICON) { PdfPCell cellSecureter = new PdfPCell(new Phrase("RESSEGURADORA USADA", fontCorpoN)); cellSecureter.setColspan(2); cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellSecureter.setPaddingTop(8f); cellSecureter.setPaddingBottom(8f); cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableSecureter.addCell(cellSecureter); pTableSecureter.addCell(cellSecureterNull); cellSecureter = new PdfPCell(new Phrase("RESSEGURA", fontCorpoN)); cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellSecureter.setPaddingTop(5f); cellSecureter.setPaddingBottom(5); pTableSecureter.addCell(cellSecureter); cellSecureter = new PdfPCell(new Phrase("%PERCENTAGEM", fontCorpoN)); cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellSecureter.setPaddingTop(5f); cellSecureter.setPaddingBottom(5); pTableSecureter.addCell(cellSecureter); pTableSecureter.addCell(cellSecureterNull); int total = listaDataEmpresas.size(); for (int i = 0; (i < total); i++) { cellSecureter = new PdfPCell(new Phrase(listaDataEmpresas.get(i).getEMPRESA(), fontCorpo)); cellSecureter.setPaddingTop(5f); cellSecureter.setPaddingBottom(5); cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableSecureter.addCell(cellSecureter); cellSecureter = new PdfPCell(new Phrase( listaDataEmpresas.get(i).getPERCENTAGEM() + "% -- " + Moeda.format(((covertDouble(listaDataEmpresas.get(i).getPERCENTAGEM()) / 100) * covertDouble(reS.getPREMIOGROSSO()))) + " " + reS.getMOEDA(), fontCorpo)); cellSecureter.setPaddingTop(5f); cellSecureter.setPaddingBottom(5); cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableSecureter.addCell(cellSecureter); pTableSecureter.addCell(cellSecureterNull); } } PdfPTable pTablePocessed = new PdfPTable(new float[] { 100 }); PdfPCell cellPocessed = new PdfPCell(new Phrase("_____________________________", fontCorpoN)); cellPocessed.setBorder(PdfPCell.NO_BORDER); cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_BOTTOM); cellPocessed.setPaddingTop(50f); cellPocessed.setPaddingBottom(1f); pTablePocessed.addCell(cellPocessed); cellPocessed = new PdfPCell(new Phrase("PROCESSED BY", fontCorpoN)); cellPocessed.setPaddingTop(1f); cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_TOP); cellPocessed.setBorder(PdfPCell.NO_BORDER); pTablePocessed.addCell(cellPocessed); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 70f, 5f); String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/"); File f = new File(f1); String Ddata = sdf1.format(new Date()); f.mkdirs(); f = new File(f.getAbsoluteFile() + "/" + "Doc Nota CO-ReSSEGURO " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Doc Nota CO-ReSSEGURO " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableLinha); documento.add(pTableLinha); /* documento.add(pTableTileDoc); documento.add(pTableLinha); */ documento.add(pTableDataPart1); documento.add(pTableLinha); documento.add(pTableDataPart2); documento.add(pTableLinha); documento.add(pTableLinha); documento.add(pTableSecureter); // documento.add(pTablePocessed); pTablePocessed.setTotalWidth(200); pTablePocessed.writeSelectedRows(-1, 100, 100f, 175f, writer.getDirectContent()); documento.close(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException | DocumentException e) { } catch (IOException ex) { Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.ExportMapaProducao__.java
public String criarDoc(String user, Date dataInicio, Date dataFim) { try {// ww w .j a v a 2 s. c o m SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); SimpleDateFormat sdfPT = new SimpleDateFormat("dd-MM-yyyy"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoTable = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoBP = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Document documento = new Document(); documento.setPageSize(PageSize.A4.rotate()); documento.setMargins(10f, 10f, 35f, 80f); File ff = new File(getDiretorio() + "/" + user + "/Relatorio/"); ff.mkdirs(); String stringData = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Producao " + stringData + ".pdf"); String reString = "../Documentos/" + user + "/Relatorio/" + "Export Mapa Producao " + stringData + ".pdf"; OutputStream outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); MyFooter event = new MyFooter(); writer.setPageEvent(event); documento.open(); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 10f, 90f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableNull = new PdfPTable(1); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); pTableNull.addCell(cellNull); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(95); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); PdfPTable pptTitileMapa = new PdfPTable(new float[] { 100 }); pptTitileMapa.setWidthPercentage(95); PdfPCell cellTitileMapa = new PdfPCell(new Phrase("Mapa de produo de ".toUpperCase() + ((dataInicio != null) ? sdfPT.format(dataInicio) + " " : " dos Ultimos anos te hoje".toUpperCase()) + ((dataFim == null) ? "" : sdfPT.format(dataFim)), fontCorpoNG)); cellTitileMapa.setBorder(0); cellTitileMapa.setHorizontalAlignment(Element.ALIGN_CENTER); pptTitileMapa.addCell(cellTitileMapa); documento.add(pptTitileMapa); documento.add(pTableNull); ResultSet rs = ud.relatorioSeguroForImpresao(dataInicio, dataFim); Consumer<HashMap<String, Object>> act = (map) -> { list = new ArrayList<>(); putNewDado(map, dataInicio, dataFim); }; Call.forEchaResultSet(act, rs); int f = 0; for (Map.Entry<String, ArrayList<Producao>> al : hasList.entrySet()) { if (f > 0) { documento.add(pTableNull); documento.add(pTableNull); } f++; PdfPTable pptTitulo = new PdfPTable(new float[] { 100 }); pptTitulo.setWidthPercentage(95); PdfPCell cellTitulo = new PdfPCell(new Phrase(al.getKey().toUpperCase(), fontCorpoNG)); cellTitulo.setBorder(0); pptTitulo.addCell(cellTitulo); documento.add(pptTitulo); documento.add(pTableNull); PdfPTable pTableDate = HeadTablePrincipal(); documento.add(pTableDate); for (Producao pro : al.getValue()) { pTableDate = new PdfPTable(new float[] { 9.7f, 28.8f, 14.7f, 10.7f, 10.7f, 10.7f, 14.7f }); pTableDate.setWidthPercentage(95); if (!pro.DATA.equals("SOMATORIO")) { newDado(pro.NUMAPOLICE, fontCorpoTable, pTableDate, documento, Element.ALIGN_LEFT, 0.5f); newDado(pro.CLIENTESEGURO, fontCorpoTable, pTableDate, documento, Element.ALIGN_LEFT, 0.5f); priencherTable(pro, fontCorpoTable, pTableDate, documento, 0.5f); } else { PdfPTable pTableDate2 = rodapeTabelaPrincipal(); newDado(("TOTAL " + al.getKey()).toUpperCase(), fontCorpoN, pTableDate2, documento, Element.ALIGN_LEFT, 1.5f); priencherTable(pro, fontCorpoBP, pTableDate2, documento, 1.5f); } } } PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); pTableAssinatura.setTotalWidth(700f); PdfPCell cellAssinatura = new PdfPCell(); cellAssinatura.setBorder(0); Paragraph assinatora = new Paragraph("DIRETOR TECNICO", fontCorpoN); assinatora.setAlignment(Element.ALIGN_CENTER); Paragraph espaco = new Paragraph(" ", fontCorpoN); Paragraph linha = new Paragraph("______________________________________", fontCorpoN); linha.setAlignment(Element.ALIGN_CENTER); cellAssinatura.addElement(assinatora); cellAssinatura.addElement(espaco); cellAssinatura.addElement(linha); pTableAssinatura.addCell(cellAssinatura); cellAssinatura = new PdfPCell(); cellAssinatura.setBorder(0); assinatora = new Paragraph("DIRETORA GERAL", fontCorpoN); assinatora.setAlignment(Element.ALIGN_CENTER); linha.setAlignment(Element.ALIGN_CENTER); cellAssinatura.addElement(assinatora); cellAssinatura.addElement(espaco); cellAssinatura.addElement(linha); pTableAssinatura.addCell(cellAssinatura); pTableAssinatura.writeSelectedRows(-1, 2, 70, 80, writer.getDirectContent()); documento.close(); // PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",0); //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",0); // printPdf.print(); return reString; } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:Export.ReciboPagamento.java
/** * new Documento Pagamento/*from w w w.j av a2s. c o m*/ * * @param Prestacao * @param user * @return String */ public String criarDoc(Integer Prestacao, String user) { try { SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); numPrestacao = Prestacao; File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Recebimento " + Ddata + ".pdf"); OutputStream outputStraem = new FileOutputStream(ff); reString = "../Documentos/" + user + "/Pagamentos/" + "Recebimento " + Ddata + ".pdf"; Document document = new Document(PageSize.A4); document.setMargins(20f, 20f, 0f, 0f); PdfWriter writer = PdfWriter.getInstance(document, outputStraem); Font fontTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 17f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontTitileShort = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontRecibo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontReciboTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontConteudoTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudoTxtUl = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC + Font.UNDERLINE, BaseColor.BLACK.darker().darker().darker()); MyFooter event = new MyFooter(); writer.setPageEvent(event); daoRecibo r = new daoRecibo(); HashMap<String, Object> map = r.getDados(); document.open(); PdfPTable table = detaDoc(map, fontTitile, fontRecibo, fontTitileShort, fontReciboTxt, fontConteudo, fontConteudoTxt, fontConteudoTxtUl); // document.add(table); // document.add(new Paragraph("\n\n\n\n\n\n\n\n\n", fontTitileShort)); // document.add(table); // document.newPage(); table.setTotalWidth(555); table.writeSelectedRows(-1, 100, 22.5f, 820f, writer.getDirectContent()); table.writeSelectedRows(-1, 100, 22.5f, 400f, writer.getDirectContent()); // table.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); document.close(); return reString; } catch (DocumentException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); return reString; } catch (FileNotFoundException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:ExternalNonFormClasses.PDFEnator.java
public void createPDF() { try {/*from ww w .j a va 2s. c o m*/ Rectangle one = new Rectangle(PageSize.LETTER); Document doc = new Document(one); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(getDirectory() + "\\" + data_title + ".pdf")); //doc.setMargins(1, 1, 1, 1); doc.open(); PdfContentByte canvas = writer.getDirectContent(); Font font = new Font(Font.FontFamily.TIMES_ROMAN, 11); x = one.getWidth(); y = one.getHeight(); tableX = (x / 2) - 235; tableY = y - 180; getHeader(); Paragraph para = new Paragraph("Province of " + formHeaderValues[0], font); para.setAlignment(Element.ALIGN_CENTER); doc.add(para); Paragraph para2 = new Paragraph("City/Municipality of " + formHeaderValues[1], font); para2.setAlignment(Element.ALIGN_CENTER); doc.add(para2); Paragraph para3 = new Paragraph("Barangay " + formHeaderValues[2], font); para3.setAlignment(Element.ALIGN_CENTER); doc.add(para3); doc.add(Chunk.NEWLINE); doc.add(Chunk.NEWLINE); Paragraph para4 = new Paragraph(data_title, font); para4.setAlignment(Element.ALIGN_CENTER); doc.add(para4); PdfPTable pdftable; pdftable = writeHeaders(font); //pdftable.writeSelectedRows(0, -1, (x / 2) - 235, y - 180, canvas); int counter = 1, rowCounter = 0, columnCounter = 0; int yIncrementor = 16; boolean test = true; while (counter <= this.totalDataSize) { //System.out.println("data#: " + counter + "@ (" + rowCounter + "," + (columnCounter) + ") = " + this.table.getValueAt(rowCounter, columnCounter).toString()); PdfPCell cell1 = new PdfPCell( new Paragraph(this.table.getValueAt(rowCounter, columnCounter++).toString(), font)); cell1.setPaddingBottom(5); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); pdftable.addCell(cell1); if (counter > 0 && (counter % column) == 0) { //if there are 4 columns //pdftable.writeSelectedRows(0, -1, (x / 2) - 235, (y - 180) - yIncrementor, canvas); //print row of 4 columns yIncrementor += 16; //move to next row coordinate, so y coordinate plus plus rowCounter++; //move to next row columnCounter = 0; //back to start column boolean newPage = false; if ((tableY - ((yIncrementor - 16) + 80)) <= 72) { //if it exceeds 1 inch in footer, new page // System.out.println("(" + tableY + "-((" + yIncrementor + "-16)+" + 16 + "))"); // System.out.println("Nanobra? YES; " + (tableY - ((yIncrementor - 16) + 16))); newPage = true; } else if ((tableY - (yIncrementor + 80)) <= 72) { // System.out.println("(" + tableY + "-(" + yIncrementor + "+" + 16 + "))"); // System.out.println("Nanobra? YES; " + (tableY - (yIncrementor + 16))); newPage = true; } if (newPage) { pdftable.completeRow(); pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); //print the data for the current page doc.newPage(); //create new page pdftable = writeHeaders(font); //write headers to new page yIncrementor = 16; //restore default } } // if (counter == this.totalDataSize) { //para lng mudouble ang data // if (test) { // test = false; // counter = 0; // rowCounter = 0; // columnCounter = 0; // } // } else if (counter == this.totalDataSize) { // if (!test) { // break; // } // } counter++; } pdftable.completeRow(); pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); doc.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(PDFEnator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ExternalNonFormClasses.PDFEnator.java
public void createProfilePDF(String id, ArrayList<String> data) { this.data_title = "Citizen Profile"; this.table = null; this.caller = 4; this.row = 17; this.column = 2; this.personID = id; this.totalDataSize = row * column; tableHeaderData = new ArrayList<>(); tableHeaderData.add("Label"); tableHeaderData.add("Information"); ArrayList<String> dataAll = data; try {//from w w w.j a v a 2s. c om getHeader(); Document doc = new Document(); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(getDirectory() + "\\" + data_title + ".pdf")); Rectangle one = new Rectangle(PageSize.LETTER); doc.setPageSize(one); //doc.setMargins(1, 1, 1, 1); doc.open(); PdfContentByte canvas = writer.getDirectContent(); Font font = new Font(Font.FontFamily.TIMES_ROMAN, 11); x = one.getWidth(); y = one.getHeight(); tableX = (x / 2) - 235; tableY = y - 180; Paragraph para = new Paragraph("Province of " + formHeaderValues[0], font); para.setAlignment(Element.ALIGN_CENTER); doc.add(para); Paragraph para2 = new Paragraph("City/Municipality of " + formHeaderValues[1], font); para2.setAlignment(Element.ALIGN_CENTER); doc.add(para2); Paragraph para3 = new Paragraph("Barangay " + formHeaderValues[2], font); para3.setAlignment(Element.ALIGN_CENTER); doc.add(para3); Paragraph para4 = new Paragraph(data_title, font); para4.setAlignment(Element.ALIGN_CENTER); doc.add(para4); PdfPTable pdftable; pdftable = writeHeaders(font); int counter = 1, rowCounter = 0, columnCounter = 0; int yIncrementor = 16; String label = null, value = null; System.out.println(dataAll.size()); while (counter <= this.row) { switch (counter - 1) { case 0: label = "Citizen ID"; value = id; break; case 1: label = "Last Name"; value = dataAll.get(counter - 2); break; case 2: label = "First Name"; value = dataAll.get(counter - 2); break; case 3: label = "Middle Name"; value = dataAll.get(counter - 2); break; case 4: label = "Name Suffix"; value = dataAll.get(counter - 2); break; case 5: label = "Date of Birth"; value = dataAll.get(counter - 2); break; case 6: label = "Gender"; value = dataAll.get(counter - 2); break; case 7: label = "Address"; value = dataAll.get(counter - 2); break; case 8: label = "Age"; value = dataAll.get(counter - 2); break; case 9: label = "Place of Birth"; value = dataAll.get(counter - 2); break; case 10: label = "Civil Status"; value = dataAll.get(counter - 2); break; case 11: label = "Contact"; value = dataAll.get(counter - 2); break; case 12: label = "Zip Code"; value = dataAll.get(counter - 2); break; case 13: label = "Precinct Number"; value = dataAll.get(counter - 2); break; case 14: label = "Occupation"; value = dataAll.get(counter - 2); break; case 15: label = "Email Address"; value = dataAll.get(counter - 2); break; case 16: label = "Religion"; value = dataAll.get(counter - 2); break; } if (value.length() <= 0) { value = "N/A"; } System.out.println(label + ": " + value); PdfPCell cell1 = new PdfPCell(new Paragraph(label, font)); cell1.setPaddingBottom(5); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); pdftable.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Paragraph(value, font)); cell2.setPaddingBottom(5); cell2.setHorizontalAlignment(Element.ALIGN_LEFT); pdftable.addCell(cell2); if (counter > 0 && (counter % column) == 0) { //if there are 4 columns yIncrementor += 16; //move to next row coordinate, so y coordinate plus plus rowCounter++; //move to next row columnCounter = 0; //back to start column boolean newPage = false; if ((tableY - ((yIncrementor - 16) + 80)) <= 72 || (tableY - (yIncrementor + 80)) <= 72) { //if it exceeds 1 inch in footer, new page newPage = true; } if (newPage) { pdftable.completeRow(); pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); //print the data for the current page doc.newPage(); //create new page pdftable = writeHeaders(font); //write headers to new page yIncrementor = 16; //restore default } } counter++; } pdftable.completeRow(); pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); doc.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(PDFEnator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fc.extensions.itext.Writer.java
License:MIT License
/** * Flush the table in memeory/* w w w.jav a 2 s . com*/ * * @param table * @param leftX * @param topY * @return Y-coord of the bottom position of table */ public float flushTable(PdfPTable table, float leftX, float topY) { // table.setTableEvent(null); return table.writeSelectedRows(0, -1, leftX, topY, pdfWriterCB); }
From source file:fll.web.report.ReportPageEventHandler.java
License:Open Source License
@Override // initialization of the header table public void onEndPage(final PdfWriter writer, final Document document) { final PdfPTable header = new PdfPTable(2); final Phrase p = new Phrase(); final Chunk ck = new Chunk(_challengeTitle + "\n" + _reportTitle, _font); p.add(ck);/* ww w . j a v a 2 s. c o m*/ header.getDefaultCell().setBorderWidth(0); header.addCell(p); header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT); header.addCell(new Phrase(new Chunk("Tournament: " + _tournament + "\nDate: " + _formattedDate, _font))); final PdfPCell blankCell = new PdfPCell(); blankCell.setBorder(0); blankCell.setBorderWidthTop(1.0f); blankCell.setColspan(2); header.addCell(blankCell); final PdfContentByte cb = writer.getDirectContent(); cb.saveState(); header.setTotalWidth(document.right() - document.left()); header.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 10, cb); cb.restoreState(); }
From source file:generators.InvoiceEventListener.java
@Override public void onEndPage(PdfWriter writer, Document document) { Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12); try {/*from w ww .ja v a 2 s . c o m*/ PdfPTable footerTable = new PdfPTable(3); footerTable.setTotalWidth(document.right(document.leftMargin())); footerTable.getDefaultCell().setBorder(Rectangle.TOP); footerTable.addCell(new Paragraph("Lionsclub Oegstgeest/Warmond", defaultFont)); footerTable.completeRow(); footerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); footerTable.addCell(new Paragraph("Betaalrekening", defaultFont)); footerTable.addCell(new Paragraph(": ************", defaultFont)); footerTable.completeRow(); footerTable.addCell(new Paragraph("Inschrijvnummer KvK Rijnland", defaultFont)); footerTable.addCell(new Paragraph(": ************ ", defaultFont)); footerTable.completeRow(); footerTable.writeSelectedRows(0, -1, document.leftMargin(), document.bottom(footerTable.getTotalHeight()) - document.bottomMargin() + 15, writer.getDirectContent()); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(String.format("%d", writer.getPageNumber()), defaultFont), document.right(), document.bottom() - document.bottomMargin() + 18, 0); } catch (Exception e) { e.printStackTrace(); } }