List of usage examples for com.itextpdf.text.pdf PdfPCell setColspan
public void setColspan(int colspan)
From source file:cis_690_report.DynamicReporter.java
private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { //create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); //set the cell alignment cell.setHorizontalAlignment(align);/* ww w . j ava 2 s . c o m*/ //set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); //in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } //add the call to the table table.addCell(cell); }
From source file:client.welcome0.java
private void insertCell(PdfPTable table, String text, int align, int colspan, com.itextpdf.text.Font font) { //create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); //set the cell alignment cell.setHorizontalAlignment(align);//from w w w . jav a 2 s . c o m //set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); //in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } //add the call to the table table.addCell(cell); }
From source file:client.welcome1.java
/** * insert single cells to the PDF file ad fills them with text * @param table/*from www .j a v a 2 s. c om*/ * @param text * @param align * @param colspan * @param font */ private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { //create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); //set the cell alignment cell.setHorizontalAlignment(align); //set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); //in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } //add the call to the table table.addCell(cell); }
From source file:cn.afterturn.easypoi.pdf.export.PdfExportServer.java
License:Apache License
private void createHeaderRow(PdfExportParams entity, PdfPTable table, int feildLength) { PdfPCell iCell = new PdfPCell(new Phrase(entity.getTitle(), styler.getFont(null, entity.getTitle()))); iCell.setHorizontalAlignment(Element.ALIGN_CENTER); iCell.setVerticalAlignment(Element.ALIGN_CENTER); iCell.setFixedHeight(entity.getTitleHeight()); iCell.setColspan(feildLength + 1); table.addCell(iCell);/*from w ww. ja v a 2 s.c om*/ if (entity.getSecondTitle() != null) { iCell = new PdfPCell( new Phrase(entity.getSecondTitle(), styler.getFont(null, entity.getSecondTitle()))); iCell.setHorizontalAlignment(Element.ALIGN_RIGHT); iCell.setVerticalAlignment(Element.ALIGN_CENTER); iCell.setFixedHeight(entity.getSecondTitleHeight()); iCell.setColspan(feildLength + 1); table.addCell(iCell); } }
From source file:cn.afterturn.easypoi.pdf.export.PdfExportServer.java
License:Apache License
private PdfPCell createStringCell(PdfPTable table, String text, ExcelExportEntity entity, int rowHeight, int colspan, int rowspan) { PdfPCell iCell = new PdfPCell(new Phrase(text, styler.getFont(entity, text))); styler.setCellStyler(iCell, entity, text); iCell.setFixedHeight((int) (rowHeight * 2.5)); if (colspan > 1) { iCell.setColspan(colspan); }//from ww w. j av a 2 s .c o m if (rowspan > 1) { iCell.setRowspan(rowspan); } table.addCell(iCell); return iCell; }
From source file:com.ashish.medicine.admin.invoice.InvoiceAction.java
private void createTable(Document document) throws DocumentException, MalformedURLException, IOException { PdfPTable table = new PdfPTable(8); table.setWidths(new int[] { 5, 10, 30, 15, 15, 15, 25, 20 }); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); // addLogo(table); String[] headerTitle = { "Sl", "Qty", "Medicine Name", "Mfg Date", "Batch", "Exp Date", "Schedule", "Price" }; Font headerFont = new Font(Font.FontFamily.TIMES_ROMAN, 10f, Font.BOLD); for (String header : headerTitle) { Phrase p = new Phrase(header, headerFont); PdfPCell c1 = new PdfPCell(p); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setLeading(0f, 1.5f);/* www.j a v a2 s . c om*/ c1.setBackgroundColor(BaseColor.GRAY); table.addCell(c1); } Font contentFont = new Font(Font.FontFamily.TIMES_ROMAN, 9f); MedicineUtility mUtil = new MedicineUtility(); // table.setSpacingAfter(20); double vat = 0.0; double discount = 0.0; int count = 1; double totalAmt = 0.0; if (totalRecords != null && totalRecords.size() > 0) { for (InvoiceBean iBean : totalRecords) { // replaceDoctor = iBean.getDoctorName(); // replaceCustomer = iBean.getCustomerName(); // replaceCustAddr1 = iBean.getCustomerAddr1(); // replaceBillNo = iBean.getBillNo(); // replaceBillDate = iBean.getPurchaseDate(); vat = iBean.getVat(); discount = iBean.getDiscount(); PdfPCell c = new PdfPCell(new Phrase(count++ + "", contentFont)); table.addCell(c); c = new PdfPCell(new Phrase(iBean.getSoldoutStock() + "", contentFont)); table.addCell(c); table.addCell(new PdfPCell(new Phrase(iBean.getMedicineName(), contentFont))); table.addCell(new PdfPCell(new Phrase(iBean.getMfgDate(), contentFont))); table.addCell(new PdfPCell(new Phrase(iBean.getBatchName(), contentFont))); table.addCell(new PdfPCell(new Phrase(iBean.getExpDate(), contentFont))); table.addCell(new PdfPCell(new Phrase(iBean.getSchedule(), contentFont))); totalAmt = totalAmt + (iBean.getSoldoutStock() * iBean.getSoldoutUnitPrice()); table.addCell(new PdfPCell(new Phrase( mUtil.getFormattedAmount((iBean.getSoldoutStock() * iBean.getSoldoutUnitPrice())), contentFont))); } } double grandTotal = 0.0; // Total PdfPCell c1 = new PdfPCell(new Phrase("Total")); c1.setColspan(7); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(mUtil.getFormattedAmount(totalAmt))); c1.setColspan(1); table.addCell(c1); // Vat c1 = new PdfPCell(new Phrase("Vat(" + vat + "%)")); c1.setColspan(7); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); double vatAmt = totalAmt * vat / 100; c1 = new PdfPCell(new Phrase(mUtil.getFormattedAmount(vatAmt))); c1.setColspan(1); table.addCell(c1); // Discount c1 = new PdfPCell(new Phrase("Discount(" + discount + "%)")); c1.setColspan(7); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); double discountAmt = totalAmt * discount / 100; c1 = new PdfPCell(new Phrase(mUtil.getFormattedAmount(discountAmt))); c1.setColspan(1); table.addCell(c1); // Grand Total c1 = new PdfPCell(new Phrase("Grand Total")); c1.setColspan(7); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); grandTotal = (totalAmt + vatAmt - discountAmt); c1 = new PdfPCell(new Phrase(mUtil.getFormattedAmount(grandTotal))); c1.setColspan(1); table.addCell(c1); document.add(table); }
From source file:com.atacadao.almoxarifado.model.GerandoPDF.java
public void pdfDeSaida(ArrayList<Equipamento> equipamentos, String solicitante, String autorizante, String responsavel, String numeroSaida) { Document documento = new Document(); try {// w ww. j a v a2 s.c om Path path = Paths.get("\\files\\saidas.pdf"); if (!Files.isDirectory(path.getParent())) { Files.createDirectory(path.getParent()); Files.createFile(path); } PdfWriter pdf; pdf = PdfWriter.getInstance(documento, new FileOutputStream("\\files\\saidas.pdf")); documento.open(); documento.addTitle("SOLICITAO DE EQUIPAMENTOS E PRODUTOS"); /** * Responsavel pelo cabealho do documento */ Image imagem = Image.getInstance("atacadao.jpg"); imagem.setAlignment(Element.ALIGN_CENTER); documento.add(imagem); Paragraph titulo = new Paragraph("SOLICITAO DE EQUIPAMENTOS E PRODUTOS", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 16, 0, BaseColor.BLACK)); titulo.setAlignment(Element.ALIGN_CENTER); documento.add(titulo); documento.setMargins(0, 0, 18, 0); Date datas = new Date(); Locale local = new Locale("pt", "BR"); SimpleDateFormat sdf = new SimpleDateFormat("E dd/MM/yyyy", local); Paragraph espaco = new Paragraph( "\n\nDeclaro para os devidos fins que eu " + solicitante + " recebi na " + sdf.format(datas) + " os equipamentos abaixo relacionados da empresa " + "Atacado dos Pisos por " + autorizante + " e autorizado por " + responsavel + ".\n", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.BLACK)); documento.add(espaco); documento.add(new Paragraph("\n Numero de registro : " + numeroSaida + "\n\n")); /** * Responsavel por cria a tabela da sada dos equipamentos */ PdfPTable pdfT = new PdfPTable(4); PdfPCell celulas = new PdfPCell(new Paragraph( "Relao de equipamentos solicitados para seus devidos fins." + " Favor caso haja devoluo manter o maximo possvel do estado atual dos mesmos. Grato !!!", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 11, 0, BaseColor.GRAY))); celulas.setColspan(4); PdfPCell patrimonio = new PdfPCell(new Paragraph("PATRIMONIO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); patrimonio.setBackgroundColor(BaseColor.GRAY); patrimonio.setPadding((float) 1); PdfPCell Nome = new PdfPCell(new Paragraph("NOME", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); Nome.setBackgroundColor(BaseColor.GRAY); Nome.setPadding((float) 1); PdfPCell Situacao = new PdfPCell(new Paragraph("SITUAO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); Situacao.setBackgroundColor(BaseColor.GRAY); Situacao.setPadding((float) 1); PdfPCell valor = new PdfPCell(new Paragraph("DESTINO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); valor.setBackgroundColor(BaseColor.GRAY); valor.setPadding((float) 1); pdfT.addCell(celulas); pdfT.addCell(patrimonio); pdfT.addCell(Nome); pdfT.addCell(Situacao); pdfT.addCell(valor); for (Equipamento equipamento : equipamentos) { PdfPCell patrimonios = new PdfPCell( new Paragraph(equipamento.getPatrimonio(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); patrimonios.setBackgroundColor(BaseColor.WHITE); Situacao.setPadding((float) 0.8); pdfT.addCell(patrimonios); PdfPCell nomes = new PdfPCell(new Paragraph(equipamento.getNome(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); nomes.setBackgroundColor(BaseColor.WHITE); nomes.setPadding((float) 0.8); pdfT.addCell(nomes); PdfPCell situacoes = new PdfPCell( new Paragraph(equipamento.getSituacao(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); situacoes.setBackgroundColor(BaseColor.WHITE); situacoes.setPadding((float) 0.8); pdfT.addCell(situacoes); PdfPCell valores = new PdfPCell(new Paragraph(equipamento.getCodigo(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); valores.setBackgroundColor(BaseColor.WHITE); valores.setPadding((float) 0.8); pdfT.addCell(valores); } documento.add(pdfT); /** * Cria tabela para assinatura do solicitante e autorizado */ PdfPTable pdfTs = new PdfPTable(5); Paragraph sol = new Paragraph("\n\n" + solicitante, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, Font.ITALIC)); sol.setAlignment(Element.ALIGN_CENTER); PdfPCell ass = new PdfPCell(sol); ass.setBorder(0); ass.setBorderWidthTop(1); ass.setColspan(2); PdfPCell espacos = new PdfPCell(); espacos.setBorder(0); Paragraph auth = new Paragraph("\n\n" + autorizante, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, Font.ITALIC)); auth.setAlignment(Element.ALIGN_CENTER); PdfPCell ass2 = new PdfPCell(auth); ass2.setBorder(0); ass2.setBorderWidthTop(1); ass2.setColspan(2); pdfTs.addCell(ass); pdfTs.addCell(espacos); pdfTs.addCell(ass2); documento.add(new Paragraph("\n\n\n")); documento.add(pdfTs); documento.close(); ImpressaoDeDocumentos imprimir = new ImpressaoDeDocumentos("\\files\\saidas.pdf"); // Desktop.getDesktop().open(new File("\\files\\saidas.pdf")); } catch (DocumentException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.cs.sis.controller.gerador.GeradorPDF.java
private PdfPTable getTableEstoqueProdutos(boolean valoresNegativos) throws DocumentException { double total_requisitado = 381624.18; Map<String, Double[]> saida = GeradorRelatorio.getRelatorioEstoqueProdutos(valoresNegativos); PdfPTable table = new PdfPTable(4); table.setWidths(new int[] { 5, 2, 1, 1 }); table.setWidthPercentage(100f);/* www . ja v a 2 s . c o m*/ table.setSpacingBefore(10f); table.setSpacingAfter(10f); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell("Produto"); table.addCell("Quantidade em Estoque"); table.addCell("Valor de Compra"); table.addCell("SubTotal"); table.getDefaultCell().setBackgroundColor(null); double quantidade = 0, total = 0; List<String> c = new ArrayList<String>(); c.addAll(saida.keySet()); Collections.sort(c); for (String produto : c) { Double[] val = saida.get(produto); double qt, vc, sub; qt = val[0]; vc = val[1]; sub = val[0] * val[1]; if (qt > 0 && qt < 10000) { quantidade += qt; total += (qt * vc); table.addCell(produto); table.addCell(new DecimalFormat("0.000").format(qt)); table.addCell(new DecimalFormat("0.00").format(vc)); table.addCell(new DecimalFormat("0.00").format(qt * vc)); } else { continue; //table.addCell(new DecimalFormat("0.00").format(val[1])); //table.addCell(new DecimalFormat("0.000").format(0)); //table.addCell(new DecimalFormat("0.00").format(vc)); //table.addCell(new DecimalFormat("0.00").format(0)); } if (total_requisitado - 10 <= total && total <= total_requisitado + 10) { break; } } table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); PdfPCell cell = new PdfPCell(new Paragraph("Total")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell(cell); //table.addCell(OperacaoStringUtil.formatarStringValorIntegerEPonto( // saida.size()) + " Produtos"); //table.addCell(OperacaoStringUtil.formatarStringQuantidadeEPonto(quantidade) // + " Itens"); String tot = OperacaoStringUtil.formatarStringValorMoedaComDescricaoEPonto(381624.18); PdfPCell cel2 = new PdfPCell(new Paragraph(tot)); cel2.setColspan(2); cel2.setHorizontalAlignment(Element.ALIGN_CENTER); cel2.setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell(cel2); //table.addCell(OperacaoStringUtil.formatarStringValorMoedaComDescricaoEPonto(total)); //System.out.println(total); return table; }
From source file:com.cs.sis.controller.gerador.GeradorPDF.java
private PdfPTable getTableEstoqueProdutos(boolean valoresNegativos, boolean paraLista, List<String> codigos_retirados, double total_requisitado) throws DocumentException { //double total_requisitado = 381624.18; Map<String, Double[]> saida = GeradorRelatorio.getRelatorioEstoqueProdutos(valoresNegativos, codigos_retirados);//from ww w .j av a 2 s.c o m PdfPTable table = new PdfPTable(4); table.setWidths(new int[] { 5, 2, 1, 1 }); table.setWidthPercentage(100f); table.setSpacingBefore(10f); table.setSpacingAfter(10f); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell("Produto"); table.addCell("Quantidade em Estoque"); table.addCell("Valor de Compra"); table.addCell("SubTotal"); table.getDefaultCell().setBackgroundColor(null); double quantidade = 0, total = 0; List<String> c = new ArrayList<String>(); c.addAll(saida.keySet()); Collections.sort(c); for (String produto : c) { if (paraLista && total_requisitado <= total) { break; } Double[] val = saida.get(produto); double qt, vc, sub; qt = val[0]; vc = val[1]; sub = val[0] * val[1]; if (qt > 0 && qt < 10000) { quantidade += qt; total += (qt * vc); table.addCell(produto); table.addCell(new DecimalFormat("0.000").format(qt)); table.addCell(new DecimalFormat("0.00").format(vc)); table.addCell(new DecimalFormat("0.00").format(qt * vc)); } else { continue; //table.addCell(new DecimalFormat("0.00").format(val[1])); //table.addCell(new DecimalFormat("0.000").format(0)); //table.addCell(new DecimalFormat("0.00").format(vc)); //table.addCell(new DecimalFormat("0.00").format(0)); } } table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); PdfPCell cell = new PdfPCell(new Paragraph("Total")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell(cell); //table.addCell(OperacaoStringUtil.formatarStringValorIntegerEPonto( // saida.size()) + " Produtos"); //table.addCell(OperacaoStringUtil.formatarStringQuantidadeEPonto(quantidade) // + " Itens"); String tot = OperacaoStringUtil.formatarStringValorMoedaComDescricaoEPonto(total_requisitado); PdfPCell cel2 = new PdfPCell(new Paragraph(tot)); cel2.setColspan(2); cel2.setHorizontalAlignment(Element.ALIGN_CENTER); cel2.setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell(cel2); //table.addCell(OperacaoStringUtil.formatarStringValorMoedaComDescricaoEPonto(total)); //System.out.println(total); return table; }
From source file:com.cs.sis.controller.gerador.GeradorPDF.java
private PdfPTable getTableBalancoProdutos(Date inicio, Date fim) throws DocumentException { Map<String, Double[]> saida = GeradorRelatorio.getRelatorioDetalhadoSaidaProduto(inicio, fim); PdfPTable table = new PdfPTable(5); table.setWidths(new int[] { 5, 1, 1, 1, 1 }); table.setWidthPercentage(100f);//from w w w .j a v a2s .co m table.setSpacingBefore(10f); table.setSpacingAfter(10f); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell("Produto"); table.addCell("Estoque"); table.addCell("Compra"); table.addCell("Venda"); table.addCell("Lucro"); table.getDefaultCell().setBackgroundColor(null); double compra = 0, venda = 0, lucro = 0, qt = 0; List<String> c = new ArrayList<String>(); c.addAll(saida.keySet()); Collections.sort(c); for (String produto : c) { table.addCell(produto); Double[] val = saida.get(produto); compra += val[0]; venda += val[1]; lucro += val[3]; qt += val[2]; table.addCell(new DecimalFormat("0.000").format(val[2])); table.addCell(new DecimalFormat("0.00").format(val[0])); table.addCell(new DecimalFormat("0.00").format(val[1])); table.addCell(new DecimalFormat("0.00").format(val[3])); } table.getDefaultCell().setBackgroundColor(new BaseColor(60, 171, 198)); PdfPCell cell = new PdfPCell(new Paragraph("Total")); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(60, 171, 198)); table.addCell(cell); table.addCell(saida.size() + " Produtos"); table.addCell(new DecimalFormat("0.000").format(qt)); table.addCell(new DecimalFormat("0.00").format(compra)); table.addCell(new DecimalFormat("0.00").format(venda)); table.addCell(new DecimalFormat("0.00").format(lucro)); return table; }