List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
From source file:nl.infosys.hartigehap.barSystem.domain.Bon.java
/** * create the table for the PDF//from w w w .ja va 2s . c o m * * @return table */ private Paragraph table() { Paragraph par = new Paragraph(); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); PdfPCell cell; Font fontbold = FontFactory.getFont("Times-Roman", 13, Font.BOLD); Font normal = FontFactory.getFont("Times-Roman", 13); table.addCell(new Phrase("Product:", fontbold)); table.addCell(new Phrase("Prijs:", fontbold)); table.addCell(new Phrase("Aantal:", fontbold)); table.addCell(new Phrase("Totaalprijs:", fontbold)); for (ImmutableProduct product : bestelling.getProducten()) { table.addCell(new Phrase(product.getNaam(), normal)); table.addCell(new Phrase(product.getPrijsFormat(), normal)); table.addCell(new Phrase(String.valueOf(product.getAantal()), normal)); cell = new PdfPCell(new Phrase(product.getTotaalPrijsFormat(), normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase("Excl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getPrijsExclBtwFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase("BTW 21%", fontbold)); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getBtwBedragFormat(), fontbold)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("Incl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getTotaalPrijsFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); par.add(table); return par; }
From source file:nl.infosys.hartigehap.barSystem.presentation.BonGui.java
private Paragraph table() { Paragraph par = new Paragraph(); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); PdfPCell cell;/*from ww w . j a v a 2 s. c o m*/ Font fontbold = FontFactory.getFont("Times-Roman", 13, Font.BOLD); Font normal = FontFactory.getFont("Times-Roman", 13); table.addCell(new Phrase("Product:", fontbold)); table.addCell(new Phrase("Prijs:", fontbold)); table.addCell(new Phrase("Aantal:", fontbold)); table.addCell(new Phrase("Totaalprijs:", fontbold)); for (ImmutableProduct product : bestelling.getProducten()) { table.addCell(new Phrase(product.getNaam(), normal)); table.addCell(new Phrase(product.getPrijsFormat(), normal)); table.addCell(new Phrase(String.valueOf(product.getAantal()), normal)); cell = new PdfPCell(new Phrase(product.getTotaalPrijsFormat(), normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase("Excl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getPrijsExclBtwFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase("BTW 21%", fontbold)); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getBtwBedragFormat(), fontbold)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("Incl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getTotaalPrijsFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); par.add(table); return par; }
From source file:nwk.com.br.documents.ClienteMaisComprouPdf.java
private PdfPTable cabecalho() throws Exception { //Cria Uma nova tabela com tres colunas, onde cada uma ocupa 20%, 20% e 60% do tamanho delas PdfPTable cabecalho = new PdfPTable(new float[] { 0.3f, 0.4f, 0.3f }); cabecalho.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento cabecalho.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); cabecalho.getDefaultCell().setBorder(0); //Instancia a imagem da logo da empresa Image img = Image.getInstance("logoorc.png");//instancia a imagem img.setAlignment(Element.ALIGN_CENTER);//alinha a imagem no centro //Cria uma linha da tabela que pegara 3 linhas com a logo nela PdfPCell logo = new PdfPCell(img); logo.setBorder(0);//from w ww .j a v a 2 s . co m logo.setRowspan(3); //adiciona a logo a tabela cabecalho.addCell(logo); //adiciona informaes da empresa a tabela cabecalho.addCell(new Phrase(new Chunk("Sos da Piscina", f))); cabecalho.addCell(new Phrase(new Chunk(formatDate.format(dia).toString(), f))); cabecalho.addCell(new Phrase(new Chunk("Avenida Rebouas, 1440 - Centro", f))); cabecalho.addCell(new Phrase(new Chunk("Sumar/SP - 13170-140", f))); cabecalho.addCell(new Phrase(new Chunk("contato@sosdapiscina.com.br", f))); cabecalho.addCell(new Phrase(new Chunk("www.sosdapiscina.com.br", f))); cabecalho.addCell(new Phrase(new Chunk("", f))); return cabecalho; }
From source file:nwk.com.br.documents.ClienteMaisComprouPdf.java
private PdfPTable getCliente() throws Exception { PdfPTable clienteMaisComprou = new PdfPTable(new float[] { 0.1f/*id*/, 0.65f/*nome*/, 0.25f/*soma*/ }); clienteMaisComprou.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento clienteMaisComprou.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); clienteMaisComprou.getDefaultCell().setBorder(0); //Adiciona os nomes das colunas PdfPCell idCliente = new PdfPCell(new Paragraph("Id")); PdfPCell nomeCliente = new PdfPCell(new Paragraph("Nome")); PdfPCell valorCliente = new PdfPCell(new Paragraph("Valor")); clienteMaisComprou.addCell(idCliente); clienteMaisComprou.addCell(nomeCliente); clienteMaisComprou.addCell(valorCliente); //Adiciona as informaes do cliente na tabela int qtdCli = 0; for (Cliente cliente : clientedao.getClienteMaisComprou()) { clienteMaisComprou.addCell(Integer.toString(cliente.getId())); clienteMaisComprou.addCell(cliente.getNome()); clienteMaisComprou.addCell("R$ " + cliente.getTotalCompra()); if (qtdCli == 19) { break; } else {/*from w ww. j a v a2 s.c o m*/ qtdCli++; } } return clienteMaisComprou; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable cabecalho(Orcamento orcamento) throws Exception { //Cria Uma nova tabela com tres colunas, onde cada uma ocupa 20%, 20% e 60% do tamanho delas PdfPTable cabecalho = new PdfPTable(new float[] { 0.3f, 0.4f, 0.3f }); cabecalho.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento cabecalho.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); cabecalho.getDefaultCell().setBorder(0); //Instancia a imagem da logo da empresa Image img = Image.getInstance("logoorc.png");//instancia a imagem img.setAlignment(Element.ALIGN_CENTER);//alinha a imagem no centro //Cria uma linha da tabela que pegara 3 linhas com a logo nela PdfPCell logo = new PdfPCell(img); logo.setBorder(0);// w ww. j a v a2s. c om logo.setRowspan(3); //adiciona a logo a tabela cabecalho.addCell(logo); //adiciona informaes da empresa a tabela cabecalho.addCell(new Phrase(new Chunk("Sos da Piscina", f))); cabecalho.addCell(new Phrase(new Chunk(formatDate.format(orcamento.getDhOrcamento()).toString(), f))); cabecalho.addCell(new Phrase(new Chunk("Avenida Rebouas, 1440 - Centro", f))); cabecalho.addCell(new Phrase(new Chunk("Sumar/SP - 13170-140", f))); cabecalho.addCell(new Phrase(new Chunk("contato@sosdapiscina.com.br", f))); cabecalho.addCell(new Phrase(new Chunk("www.sosdapiscina.com.br", f))); cabecalho.addCell(new Phrase(new Chunk("", f))); return cabecalho; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosCliente(Orcamento orcamento) throws Exception { cliente = clientedao.select(orcamento.getIdCliente()); PdfPTable dadosCliente = new PdfPTable(new float[] { 0.35f, 0.35f, 0.3f }); dadosCliente.setWidthPercentage(90.0f);//seta o tamanho da tabela em relaao ao documento dadosCliente.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);//alinha os dados a esquerda dadosCliente.getDefaultCell().setBorder(0);//retira a borda //Cria uma cedula da tabela que pegara tres colunas PdfPCell nomeCli = new PdfPCell(new Paragraph("Nome: " + cliente.getNome(), f)); nomeCli.setColspan(3);/*w w w . java2 s .c o m*/ nomeCli.setHorizontalAlignment(Element.ALIGN_LEFT); nomeCli.setBorder(0); dadosCliente.addCell(nomeCli); //formatao do celular e do telefone String celular = new String(); String telefone = new String(); celular = "(" + cliente.getCelular().substring(0, 2) + ") " + cliente.getCelular().substring(2); telefone = "(" + cliente.getTelefone().substring(0, 2) + ") " + cliente.getCelular().substring(2); //adciona os demais dados do cliente a tabela dadosCliente.addCell("E-mail: " + cliente.getEmail()); dadosCliente.addCell("Telefone: " + telefone); dadosCliente.addCell("Celular: " + celular); dadosCliente.addCell("Rua: " + cliente.getRua() + ", " + cliente.getNumero()); dadosCliente.addCell("Bairro: " + cliente.getBairro()); dadosCliente.addCell("Complemento: " + cliente.getComplemento()); dadosCliente.addCell(cliente.getCidade() + "/" + cliente.getEstado()); dadosCliente.addCell(cliente.getCep()); return dadosCliente; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosProdutos(Orcamento orcamento) throws Exception { PdfPTable produtosOrc = new PdfPTable(new float[] { 0.1f/*cod*/, 0.45f/*descri*/, 0.1f/*qtd*/, 0.2f/*valuni*/, 0.15f/*descon*/, 0.2f/*total*/ }); produtosOrc.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento produtosOrc.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); produtosOrc.getDefaultCell().setBorder(0); //Adiciona os nomes das colunas PdfPCell codProd = new PdfPCell(new Paragraph("Cod")); PdfPCell descProd = new PdfPCell(new Paragraph("Descrio")); PdfPCell qtdProd = new PdfPCell(new Paragraph("Qtd")); PdfPCell valProd = new PdfPCell(new Paragraph("Valor Unitario")); PdfPCell desProd = new PdfPCell(new Paragraph("Desconto")); PdfPCell totalProd = new PdfPCell(new Paragraph("Total")); produtosOrc.addCell(codProd);//from w w w . j a v a2 s . com produtosOrc.addCell(descProd); produtosOrc.addCell(qtdProd); produtosOrc.addCell(valProd); produtosOrc.addCell(desProd); produtosOrc.addCell(totalProd); //Adiciona as informaes dos produtos na tabela for (Produto produto : orcamentodao.getTodosProdutosOrcamento(orcamento)) { produtosOrc.addCell(produto.getId()); produtosOrc.addCell(produto.getDescricao()); produtosOrc.addCell(produto.getQuantidade()); produtosOrc.addCell("R$ " + produto.getValorVenda()); produtosOrc.addCell("R$ " + produto.getDesconto()); produtosOrc.addCell("R$ " + produto.getTotal()); } return produtosOrc; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosPagamento(Orcamento orcamento) throws Exception { Font fontTotal = new Font(Font.FontFamily.TIMES_ROMAN, 16); PdfPTable dPagamento = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f }); dPagamento.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento dPagamento.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); dPagamento.getDefaultCell().setBorder(0); //celula com espao em branco e com o Total PdfPCell spc = new PdfPCell(new Paragraph(" ")); PdfPCell total = new PdfPCell(new Paragraph("TOTAL: R$" + orcamento.getTotal(), fontTotal)); //alinha a celula total a esquerda total.setHorizontalAlignment(Element.ALIGN_RIGHT); spc.setColspan(3);// www. jav a 2s . co m total.setBorder(0); spc.setBorder(0); if (orcamento.getFormaPagamento().equals("0")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: A vista - Dinheiro", f)); } else if (orcamento.getFormaPagamento().equals("1")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: A vista - Carto", f)); } else if (orcamento.getFormaPagamento().equals("2")) { dPagamento.addCell(new Paragraph("Forma de Pagamento: Parcelado", f)); } dPagamento.addCell(new Paragraph("Desconto: R$" + orcamento.getDesconto(), f)); dPagamento.addCell(total); return dPagamento; }
From source file:nwk.com.br.documents.OrcamentoPdf.java
private PdfPTable dadosRodape(Orcamento orcamento) throws Exception { //tabela que pega com 100% do tamanho do arquivo, alinhada no centro com tres colunas e sem bordas PdfPTable rodape = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f }); rodape.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento rodape.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); rodape.getDefaultCell().setBorder(0); PdfPCell obs = new PdfPCell(new Paragraph("\n\n Observaes:\n" + orcamento.getObservacoes(), f)); PdfPCell ass = new PdfPCell(new Paragraph("\n\n_________________________\nAssinatura", f)); Font fonteAviso = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLDITALIC); PdfPCell spc = new PdfPCell(new Paragraph(" ")); PdfPCell aviso = new PdfPCell(new Paragraph( "AGRADEEMOS A PREFERNCIA\nORAMENTO VALIDO SOMENTE PARA O DIA DE SUA CRIAO!", fonteAviso)); aviso.setHorizontalAlignment(Element.ALIGN_CENTER); obs.setHorizontalAlignment(Element.ALIGN_LEFT); ass.setHorizontalAlignment(Element.ALIGN_CENTER); obs.setBorder(0);/*from www . jav a2 s. com*/ ass.setBorder(0); spc.setBorder(0); aviso.setBorder(0); spc.setColspan(3); aviso.setColspan(3); rodape.addCell(obs); rodape.addCell(new Paragraph(" ")); rodape.addCell(ass); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(spc); rodape.addCell(aviso); //rodape.setExtendLastRow(true); //cria uma nova celula que recebe a tabela anterior PdfPCell otherCell = new PdfPCell(rodape); otherCell.setBorder(0); otherCell.setVerticalAlignment(Element.ALIGN_BOTTOM); otherCell.setHorizontalAlignment(Element.ALIGN_CENTER); //cria uma nova tabela que recebe a celula otherCell PdfPTable rodape2 = new PdfPTable(new float[] { 1.0f }); rodape2.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento rodape2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); rodape2.getDefaultCell().setBorder(0); //estende a tabela at o fim da pagina, como o alinhamento horizontal dela bottom, ela fica toda no rodape rodape2.addCell(otherCell); rodape2.setExtendLastRow(true); return rodape2; }
From source file:nwk.com.br.documents.ProdutoMaisVendidoPdf.java
private PdfPTable getProduto() throws Exception { PdfPTable produtoMaisVendido = new PdfPTable(new float[] { 0.1f/*id*/, 0.65f/*nome*/, 0.25f/*soma*/ }); produtoMaisVendido.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento produtoMaisVendido.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); produtoMaisVendido.getDefaultCell().setBorder(0); //Adiciona os nomes das colunas PdfPCell codProduto = new PdfPCell(new Paragraph("Cod")); PdfPCell descProduto = new PdfPCell(new Paragraph("Descrio")); PdfPCell qtdProduto = new PdfPCell(new Paragraph("Quantidade")); produtoMaisVendido.addCell(codProduto); produtoMaisVendido.addCell(descProduto); produtoMaisVendido.addCell(qtdProduto); //Adiciona as informaes do cliente na tabela int qtdCli = 0; for (Produto produto : produtodao.getProdutoeMaisVendido()) { produtoMaisVendido.addCell(produto.getId()); produtoMaisVendido.addCell(produto.getDescricao()); produtoMaisVendido.addCell(produto.getQuantidade()); if (qtdCli == 19) { break; } else {//from ww w.jav a 2 s . c o m qtdCli++; } } return produtoMaisVendido; }