List of usage examples for com.itextpdf.text Image scaleToFit
public void scaleToFit(final float fitWidth, final float fitHeight)
From source file:utils.pdf.cv_templates.Template3.java
private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException, IOException { Paragraph paragraph1, paragraph2;//from w w w . j ava 2 s. com PdfPCell cell1, cell2, cell3; PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Experiencia Profesional", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); // TABLE 3 for (int i = 0; i < experienceList.size(); i++) { table3 = new PdfPTable(new float[] { 6, 4 }); table3.setWidthPercentage(100); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(experienceList.get(i).job.toUpperCase() + ".\n" + experienceList.get(i).company.toUpperCase() + ".", font3); paragraph2.setSpacingBefore(10); cell3.addElement(paragraph2); table3.addCell(cell3); //Second column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(experienceList.get(i).startDate.toUpperCase() + " - " + experienceList.get(i).endDate.toUpperCase() + ".", font3); paragraph2.setAlignment(paragraph2.ALIGN_LEFT); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template3.java
private void addSoftware(List<Software> softwareList) throws DocumentException, IOException { Paragraph paragraph1, paragraph2;//from w w w . j a va2s. c o m PdfPCell cell1, cell2, cell3; PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Programas informticos", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); // TABLE 3 for (int i = 0; i < softwareList.size(); i++) { table3 = new PdfPTable(new float[] { 6, 4 }); table3.setWidthPercentage(100); table3.setSpacingBefore(5); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(softwareList.get(i).software + ".", font3); paragraph2.setSpacingBefore(10); cell3.addElement(paragraph2); table3.addCell(cell3); //Second column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(softwareList.get(i).level + ".", font3); paragraph2.setAlignment(paragraph2.ALIGN_LEFT); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template3.java
private void addLanguages(List<Language> languages) throws DocumentException, IOException { Paragraph paragraph1, paragraph2;// www . ja v a 2 s.co m PdfPCell cell1, cell2, cell3; PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Idiomas", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); //TABLE 3 for (int i = 0; i < languages.size(); i++) { table3 = new PdfPTable(new float[] { 6 }); table3.setWidthPercentage(100); table3.setSpacingBefore(5); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(languages.get(i).language + ". " + languages.get(i).level + ".", font3); paragraph2.setSpacingBefore(10); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template3.java
private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { Paragraph paragraph1, paragraph2;/*from w w w.j av a 2 s . c o m*/ PdfPCell cell1, cell2, cell3; PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Cualidades", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); // TABLE 3 List<String> rankedSkills = selectSkills(skills); if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) { table3 = new PdfPTable(new float[] { 6 }); table3.setWidthPercentage(100); table3.setSpacingBefore(5); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph( "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase() + " y " + personalCharacteristics.get(0).toLowerCase() + ".", font3); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.setPaddingTop(-1); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase() + " y las " + rankedSkills.get(1).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph( "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph("Adems, una de las caractersticas que me define es que soy " + personalCharacteristics.get(2).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addImage(User user) throws DocumentException, IOException { Image photo_img; if (!user.photo.id.equals("")) { photo_img = Image/*from w ww . j a va 2s. c o m*/ .getInstance(String.format("https://s3.amazonaws.com/aunclickdelempleo2/" + user.photo.id)); } else { photo_img = Image.getInstance(String.format("public/images/orientation/photo/ic_profile.png")); } photo_img.setAbsolutePosition(450, 690); photo_img.setAlignment(Image.LEFT | Image.TEXTWRAP); photo_img.setBorder(Image.BOX); photo_img.setBorderWidth(10); photo_img.setBorderColor(BaseColor.WHITE); photo_img.scaleToFit(1000, 115); document.add(photo_img); }
From source file:View.TelaRelatorio.java
public void GerarPDF() { Document documentoPDF = new Document(); try {/*from w w w . jav a 2 s. c om*/ PdfWriter.getInstance(documentoPDF, new FileOutputStream("C:\\Users\\Marilia Nayara\\Desktop\\PDFRelatorio.pdf")); documentoPDF.open(); documentoPDF.setPageSize(PageSize.A4); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD); Paragraph cabecalho = new Paragraph("Teste De SI", fonte); cabecalho.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(cabecalho); Image imagem = Image.getInstance( "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\imagem2.jpg"); imagem.scaleToFit(400, 300); documentoPDF.add(imagem); } catch (DocumentException de) { de.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { documentoPDF.close(); } }
From source file:View.TelaRelatorio.java
public void GerarEntrega(int codigo) throws IOException { NegociosCompra nc = new NegociosCompra(); Compra compra = nc.ConsultarCompra(codigo); Document documentoPDF = new Document(); String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\VendasEntrega\\Compra" + codigo + ".pdf"; try {//from w w w . j av a2s.c o m PdfWriter.getInstance(documentoPDF, new FileOutputStream(output)); documentoPDF.open(); documentoPDF.setPageSize(PageSize.A4); Image imagem = Image.getInstance( "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png"); imagem.scaleToFit(100, 75); imagem.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(imagem); Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD); Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1); agr.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(agr); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD); Paragraph cabecalho = new Paragraph("COMPRA ENTREGA", fonte); cabecalho.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(cabecalho); documentoPDF.add(new Paragraph("\n")); Cliente c = new NegociosCliente().ProcurarCliente(compra.getCpf_c()); Timestamp t = compra.getData(); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); String a = formato.format(t); PdfPTable dadosC = new PdfPTable(new float[] { 0.10f, 0.70f, 0.20f }); List<String> dados = new ArrayList<String>(); dados.add("CODIGO DA COMPRA"); dados.add("CLIENTE"); dados.add("DATA DA COMPRA"); dados.add("" + compra.getCodigo()); dados.add(c.getNome()); dados.add(a); for (String s : dados) { dadosC.addCell(s); } dadosC.setWidthPercentage(110f); documentoPDF.add(dadosC); documentoPDF.add(new Paragraph("\n")); /*documentoPDF.add(new Paragraph(" LISTA DE PRODUTOS COMPRADOS")); documentoPDF.add(new Paragraph("\n")); documentoPDF.add(new Paragraph("Codigo Produto Valor Unitrio Quantidade Valor ")); String tam = "Codigo Produto Valor Unitrio Quantidade Valor "; JOptionPane.showMessageDialog(null, tam.length()); for(int x=0;x<compra.getLista_prod().size();x++){ Produto p = new NegociosProduto().ProcurarProduto(compra.getLista_prod().get(x).intValue()); String cod = ""+p.getCodigo(); String nome = p.getNome(); float pv = p.getPvenda(); String pvs = ""+pv; int quant = compra.getQuantidades().get(x).intValue(); String squant = ""+quant; float pf = pv*quant; String spf = ""+pf; int espaco = 13 - cod.length(); String esp = ""; for(int y = 0;y <espaco;y++){ esp=esp+" "; } cod = cod+esp; espaco = 49 - nome.length(); esp = ""; for(int y = 0;y <espaco;y++){ esp=esp+" "; } nome = nome + esp; espaco = 24 - pvs.length(); esp = ""; for(int y = 0;y <espaco;y++){ esp=esp+" "; } pvs = pvs + esp; espaco = 23 - squant.length(); esp = ""; for(int y = 0;y <espaco;y++){ esp=esp+" "; } squant = squant + esp; espaco = 8 - spf.length(); esp = ""; for(int y = 0;y <espaco;y++){ esp=esp+" "; } spf = spf + esp; String fina = cod+nome+pvs+squant+spf; //JOptionPane.showMessageDialog(null, fina.length()); documentoPDF.add(new Paragraph(fina)); }*/ Font fonte3 = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL); // Criando uma tabela com 3 colunas PdfPTable table = new PdfPTable(new float[] { 0.1f, 0.45f, 0.15f, 0.15f, 0.15f }); table.setWidthPercentage(110.f); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("LISTA DE PRODUTOS COMPRADOS", fonte3); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 3 colunas header.setColspan(5); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela table.addCell(header); List<String> list = new ArrayList<String>(); list.add("CODIGO"); list.add("PRODUTO"); list.add("VALOR UNIT?RIO"); list.add("QUANTIDADE"); list.add("VALOR"); for (int x = 0; x < compra.getLista_prod().size(); x++) { Produto p = new NegociosProduto().ProcurarProduto(compra.getLista_prod().get(x).intValue()); String cod = "" + p.getCodigo(); String nome = p.getNome(); float pv = p.getPvenda(); String pvs = "" + pv; int quant = compra.getQuantidades().get(x).intValue(); String squant = "" + quant; float pf = pv * quant; String spf = "" + pf; list.add(cod); list.add(nome); list.add(pvs); list.add(squant); list.add(spf); } for (String s : list) { table.addCell(s); } documentoPDF.add(table); documentoPDF.add(new Paragraph("\n")); Paragraph total = new Paragraph("Total: " + compra.getPreco_final(), fonte3); total.setAlignment(Element.ALIGN_RIGHT); documentoPDF.add(total); documentoPDF.add(new Paragraph("\n")); PdfPTable endereco = new PdfPTable(new float[] { 0.30f, 0.80f }); endereco.setWidthPercentage(60f); endereco.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph tableH = new Paragraph("ENDEREO DE ENTREGA", fonte3); PdfPCell hea = new PdfPCell(tableH); hea.setColspan(2); hea.setHorizontalAlignment(Paragraph.ALIGN_CENTER); endereco.addCell(hea); List<String> dadosE = new ArrayList<String>(); dadosE.add("LOGRADOURO"); dadosE.add(c.getEndereco().getRua()); dadosE.add("NUMERO"); dadosE.add("" + c.getEndereco().getNumero()); dadosE.add("BAIRRO"); dadosE.add(c.getEndereco().getBairro()); dadosE.add("CIDADE"); dadosE.add(c.getEndereco().getCidade()); dadosE.add("ESTADO"); dadosE.add(c.getEndereco().getEstado()); for (String s : dadosE) { endereco.addCell(s); } documentoPDF.add(endereco); documentoPDF.add(new Paragraph("\n")); documentoPDF .add(new Paragraph("Assinatura: __________________________________________________________")); Paragraph ass = new Paragraph("(" + c.getNome() + ")", fonte1); ass.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(ass); documentoPDF.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); Paragraph comp = new Paragraph("COMPROVANTE DE ENTREGA"); comp.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(comp); documentoPDF.add(new Paragraph("\n")); documentoPDF.add(dadosC); documentoPDF.add(total); documentoPDF .add(new Paragraph("Assinatura: __________________________________________________________")); documentoPDF.add(ass); } catch (DocumentException de) { de.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { documentoPDF.close(); java.awt.Desktop.getDesktop().open(new File(output)); } }
From source file:View.TelaRelatorio.java
public void GerarVendidosSemana(String inicio, String Final) throws FileNotFoundException, BadElementException, IOException { NegocioRelatorio nr = new NegocioRelatorio(); Document documentoPDF = new Document(); String nome = inicio.toString(); String comp = Final.toString(); String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\MVdia.pdf"; try {//from w ww . j ava2 s .co m PdfWriter.getInstance(documentoPDF, new FileOutputStream(output)); documentoPDF.open(); documentoPDF.setPageSize(PageSize.A4); Image imagem = Image.getInstance( "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png"); imagem.scaleToFit(100, 75); imagem.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(imagem); Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD); Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1); agr.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(agr); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD); Paragraph cabecalho = new Paragraph("MAIS VENDIDAS DA SEMANA", fonte); cabecalho.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(cabecalho); documentoPDF.add(new Paragraph("\n")); List<MaisVendidos> mv = nr.MaisVendidos(inicio, Final); System.out.println("voltou"); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); List<Timestamp> gamb = new ArrayList<Timestamp>(); String aux; String aux1; for (int j = 0; j < mv.size(); j++) { int gam = 0; Date d = new Date(mv.get(j).getData().getTime()); aux = formato.format(d); for (int i = 0; i < gamb.size(); i++) { aux1 = formato.format(gamb.get(i).getTime()); if (aux.equals(aux1)) { gam = 1; System.out.println("entroy aki"); } } if (gam == 0) { gamb.add(mv.get(j).getData()); System.out.println(j); String a = formato.format(mv.get(j).getData()); Calendar cal = Calendar.getInstance(); cal.setTime(mv.get(j).getData());// ========> Objeto Date int day = cal.get(Calendar.DAY_OF_WEEK); Paragraph dia = new Paragraph(); if (day == 1) { dia = new Paragraph("DOMINGO " + a); } else if (day == 2) { dia = new Paragraph("SEGUNDA-FEIRA " + a); } else if (day == 3) { dia = new Paragraph("TERA-FEIRA " + a); } else if (day == 4) { dia = new Paragraph("QUARTA-FEIRA " + a); } else if (day == 5) { dia = new Paragraph("QUINTA-FEIRA " + a); } else if (day == 6) { dia = new Paragraph("SEXTA-FEIRA " + a); } else if (day == 7) { dia = new Paragraph("SABADO " + a); } documentoPDF.add(dia); documentoPDF.add(new Paragraph("\n")); PdfPTable dadosC = new PdfPTable(new float[] { 0.30f, 0.50f, 0.15f, 0.15f }); List<String> dados = new ArrayList<String>(); dados.add("CATEGORIA"); dados.add("PRODUTO"); dados.add("QUANTIDADE"); dados.add("VALOR"); List<String> categorias = new ArrayList<String>(); for (int x = 0; x < mv.size(); x++) { String aux2 = formato.format(mv.get(x).getData().getTime()); int contc = 0; System.out.println(aux); System.out.println(aux2); if (aux.equals(aux2)) { Categoria c = new NegociosCategoria().ProcurarCategoria(mv.get(x).getIdent()); for (int k = 0; k < categorias.size(); k++) { if (c.getNome().equals(categorias.get(k).toString())) { contc = 1; } } if (contc == 0) { categorias.add(c.getNome()); dados.add(c.getNome()); Produto p = new NegociosProduto().ProcurarProduto(mv.get(x).getCodigo()); dados.add(p.getNome()); dados.add("" + mv.get(x).getQuantidade()); double valor = mv.get(x).getQuantidade() * mv.get(x).getPtotal(); dados.add("" + valor); } } } for (String s : dados) { dadosC.addCell(s); } dadosC.setWidthPercentage(110f); documentoPDF.add(dadosC); } } } catch (DocumentException de) { de.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { documentoPDF.close(); java.awt.Desktop.getDesktop().open(new File(output)); } }
From source file:View.TelaRelatorio.java
public void GerarEntregas() throws DocumentException, FileNotFoundException, BadElementException, IOException { NegocioRelatorio nr = new NegocioRelatorio(); Document documentoPDF = new Document(); String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\EntregasRealizadas.pdf"; try {// w w w. j a va2 s.co m PdfWriter.getInstance(documentoPDF, new FileOutputStream(output)); documentoPDF.open(); documentoPDF.setPageSize(PageSize.A4); Image imagem = Image.getInstance( "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png"); imagem.scaleToFit(100, 75); imagem.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(imagem); Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD); Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1); agr.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(agr); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD); Paragraph cabecalho = new Paragraph("ENTREGAS REALIZADAS", fonte); cabecalho.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(cabecalho); documentoPDF.add(new Paragraph("\n\n")); List<EntregasRealizadas> ER = nr.EntregasRealizadas(); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); int d = 0, se = 0, te = 0, qa = 0, qi = 0, sex = 0, sa = 0; for (int x = 0; x < ER.size(); x++) { String a = formato.format(ER.get(x).getDatas()); Calendar cal = Calendar.getInstance(); cal.setTime(ER.get(x).getDatas());// ========> Objeto Date int day = cal.get(Calendar.DAY_OF_WEEK); if (day == 1) { d = d + ER.get(x).getQuant(); } else if (day == 2) { se = se + ER.get(x).getQuant(); } else if (day == 3) { te = te + ER.get(x).getQuant(); } else if (day == 4) { qa = qa + ER.get(x).getQuant(); } else if (day == 5) { qi = qi + ER.get(x).getQuant(); } else if (day == 6) { sex = sex + ER.get(x).getQuant(); } else if (day == 7) { sa = sa + ER.get(x).getQuant(); } } PdfPTable dadosC = new PdfPTable(new float[] { 0.50f, 0.50f }); List<String> dados = new ArrayList<String>(); dados.add("DIA"); dados.add("QUANTIDADE"); dados.add("DOMINGO"); dados.add("" + d); dados.add("SEGUNDA-FEIRA"); dados.add("" + se); dados.add("TERA-FEIRA"); dados.add("" + te); dados.add("QUARTA-FEIRA"); dados.add("" + qa); dados.add("QUINTA-FEIRA"); dados.add("" + qi); dados.add("SEXTA-FEIRA"); dados.add("" + sex); dados.add("SABADO"); dados.add("" + sa); for (String s : dados) { dadosC.addCell(s); } dadosC.setWidthPercentage(60f); dadosC.setHorizontalAlignment(Element.ALIGN_CENTER); documentoPDF.add(dadosC); } catch (DocumentException de) { de.printStackTrace(); } finally { documentoPDF.close(); java.awt.Desktop.getDesktop().open(new File(output)); } }
From source file:View.TelaRelatorio.java
public void EntregasPorLocalidade() { NegocioRelatorio nr = new NegocioRelatorio(); Document documentoPDF = new Document(); String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\EntregasPorLocalidades.pdf"; try {/*from w w w . j a v a2 s . c om*/ PdfWriter.getInstance(documentoPDF, new FileOutputStream(output)); documentoPDF.open(); documentoPDF.setPageSize(PageSize.A4); Image imagem = Image.getInstance( "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png"); imagem.scaleToFit(100, 75); imagem.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(imagem); Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD); Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1); agr.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(agr); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD); Paragraph cabecalho = new Paragraph("ENTREGAS POR LOCALIDADE", fonte); cabecalho.setAlignment(Element.ALIGN_CENTER); documentoPDF.add(cabecalho); documentoPDF.add(new Paragraph("\n\n")); List<Entrega> Entrega = nr.Localidades(); PdfPTable dadosC = new PdfPTable(new float[] { 0.50f, 0.50f }); List<String> dados = new ArrayList<String>(); dados.add("BAIRRO"); dados.add("TOTAL DE ENTREGAS"); for (int x = 0; x < Entrega.size(); x++) { dados.add(Entrega.get(x).getDia()); dados.add("" + Entrega.get(x).getQuant()); } for (String s : dados) { dadosC.addCell(s); } dadosC.setWidthPercentage(100f); dadosC.setHorizontalAlignment(Element.ALIGN_CENTER); documentoPDF.add(dadosC); } catch (DocumentException ex) { Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex); } finally { documentoPDF.close(); try { java.awt.Desktop.getDesktop().open(new File(output)); } catch (IOException ex) { Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex); } } }