List of usage examples for com.itextpdf.text Element ALIGN_LEFT
int ALIGN_LEFT
To view the source code for com.itextpdf.text Element ALIGN_LEFT.
Click Source Link
From source file:Export.FuncPagamento.java
private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) { OutputStream outputStraem;//from w w w .ja va 2s . c o m try { SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR")); SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR")); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 14f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f, Font.UNDERLINE); // Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f ); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); // Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 10f, 5f); String Ddata = sdf1.format(new Date()); ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento); int total = mapList.size(); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/"); ff.mkdirs(); ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); MyFooterA5 event = new MyFooterA5(); writer.setPageEvent(event); documento.open(); PdfPTable pTableTitile = new PdfPTable(new float[] { 100 }); pTableTitile.setWidthPercentage(95f); PdfPCell cellTitile = new PdfPCell(); cellTitile.setBorder(0); Paragraph pTitile = new Paragraph(); pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG)); pTitile.setAlignment(Element.ALIGN_CENTER); PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 }); pTableSubTitile.setWidthPercentage(101f); PdfPCell cellSubTitile = new PdfPCell( new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN)); cellSubTitile.setBorder(0); cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT); cellSubTitile.setPaddingBottom(20); cellSubTitile.setPaddingRight(67); cellSubTitile.setPaddingTop(10); pTableSubTitile.addCell(cellSubTitile); cellSubTitile = new PdfPCell( new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(), fontCabecalhoN)); cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT); cellSubTitile.setBorder(0); cellSubTitile.setPaddingBottom(20); cellSubTitile.setPaddingTop(10); pTableSubTitile.addCell(cellSubTitile); // pTitile.add(cellSubTitile); pTitile.add(pTableSubTitile); cellTitile.addElement(pTitile); pTableTitile.addCell(cellTitile); documento.add(pTableTitile); PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f }); pTableDados.setWidthPercentage(95f); PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); Double toPa = 0.0; for (int j = 0; j < total; j++) { int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length; float pad = setPadding(total, tLinha); cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toMoeda( (toDouble(mapList.get(j).get(VALORPAGAMENTO)) / (float) toInt(mapList.get(j).get(QUANTIDADE))), toString(mapList.get(j).get(SIGLA))), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase( toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO)); } // 5.6f,5.6f,53.5f,17.95f,19.45f PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f }); pTableRodape.setWidthPercentage(95f); cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG)); pTableRodape.addCell(cellDados); documento.add(pTableDados); documento.add(pTableRodape); PdfPTable pTableAssiEstenso = new PdfPTable(new float[] { 100f }); pTableAssiEstenso.setWidthPercentage(95f); PdfPCell cellAssiEstenso = new PdfPCell(); Paragraph pAssiEstenso = new Paragraph(); PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 }); pTableResposavel.setWidthPercentage(100f); PdfPCell cellResposavel = new PdfPCell(); cellResposavel .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN)); cellResposavel.setPaddingTop(10f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN)); cellResposavel.setPaddingTop(10f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN)); cellResposavel.setPaddingTop(-5f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN)); cellResposavel.setPaddingTop(-5f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); pAssiEstenso.add(pTableResposavel); cellAssiEstenso.addElement(pAssiEstenso); PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f }); pTableExteso.setWidthPercentage(100f); JTextPane jtp = new JTextPane(); Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : "")); PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN)); cellExteso.setBorder(0); pTableExteso.addCell(cellExteso); cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU)); cellExteso.setBorder(0); pTableExteso.addCell(cellExteso); pAssiEstenso.add(pTableExteso); PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f }); pTableAss.setWidthPercentage(100f); PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN)); cellAss.setPaddingTop(15f); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); cellAss.setPaddingBottom(0f); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN)); cellAss.setPaddingTop(15f); cellAss.setPaddingBottom(0f); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase("Date", fontCorpoN)); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN)); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER); pAssiEstenso.add(pTableAss); pAssiEstenso.setAlignment(Element.ALIGN_CENTER); pAssiEstenso.add(new Phrase( "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n", fontCorpoN)); cellAssiEstenso = new PdfPCell(); cellAssiEstenso.addElement(pAssiEstenso); pTableAssiEstenso.addCell(cellAssiEstenso); documento.add(pTableAssiEstenso); documento.close(); reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf"; return reString; } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.ReciboPagamento.java
public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort, Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl) throws DocumentException { PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 }); try {// w ww . ja va 2s . c o m pTablePrincipal.setWidthPercentage(100f); PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 }); pTableTitulo.setWidthPercentage(100); PdfPTable pTableTituloImage = new PdfPTable(new float[] { 20, 80 }); pTableTituloImage.setWidthPercentage(100); PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingTop(20f); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo)); cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM); cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setPaddingLeft(70f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setVerticalAlignment(Element.ALIGN_TOP); cellTitulo.setPaddingBottom(30f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); imageEmpresa.setAlignment(Image.ALIGN_CENTER); PdfPCell cellImagem = new PdfPCell(imageEmpresa); cellImagem.setBorder(PdfPCell.NO_BORDER); cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo); cellpTableTitulo.setBorder(PdfPCell.NO_BORDER); cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableTituloImage.addCell(cellImagem); pTableTituloImage.addCell(cellpTableTitulo); PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage); cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellpTableTituloPrincipal); PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f }); pTableDataCaixaMontante.setWidthPercentage(100f); PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); cellDataCaixaMontante.setBorder(0); Paragraph p = new Paragraph(); p.add(new Phrase("Data: ".toUpperCase(), fontRecibo)); p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt)); p.setAlignment(Element.ALIGN_RIGHT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingBottom(5f); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo)); p.add(new Phrase("So Tom", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo)); Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO))); // SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:"); Object dRegistro = map.get(DATAREGAPOLICE); montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante); cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellDataCaixaMontantePrincipal); PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 }); pTableConteudo.setWidthPercentage(100f); PdfPCell cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); Paragraph pConteudo = new Paragraph(); pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt)); /** * For alter */ pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("FGA: ", fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo)); pConteudo.add( new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt)); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); pConteudo = new Paragraph(); pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt)); PdfPTable pTableNomeCod = new PdfPTable(new float[] { 70, 30 }); pTableNomeCod.setWidthPercentage(100); Paragraph pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt)); PdfPCell cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pConteudo.add(pTableNomeCod); JTextPane jtp = new JTextPane(); Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + "")); valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); Moeda.EscreverEstenso(valor, jtp, "Dobras"); pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt)); PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 }); pTableApoliceDatasP.setWidthPercentage(100); PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 }); pTableApoliceDatas.setWidthPercentage(100); for (int i = 0; i < 1; i++) { PdfPCell cellApolice = new PdfPCell(); Paragraph pApolice = new Paragraph(); pApolice.add(new Phrase("N ", fontConteudo)); pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt)); cellApolice.addElement(pApolice); cellApolice.setPaddingTop(-2f); cellApolice.setPaddingBottom(2f); cellApolice.setBorder(0); pTableApoliceDatas.addCell(cellApolice); PdfPCell cellDatas = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt)); cellDatas.addElement(pDatas); cellDatas.setBorder(0); cellDatas.setPaddingTop(-2f); cellDatas.setPaddingBottom(2f); pTableApoliceDatas.addCell(cellDatas); } PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo)); cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); cellApoliceP = new PdfPCell(pTableApoliceDatas); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); pConteudo.add(pTableApoliceDatasP); // PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f }); pTableTipoPagemento.setWidthPercentage(100f); PdfPCell cellTipoPageme = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); cellTipoPageme = new PdfPCell(); pDatas = new Paragraph(); pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); pConteudo.add(pTableTipoPagemento); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo)); cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellConteudoPrincipal); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); pTableAssinatura.setWidthPercentage(100f); Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker()); PdfPCell cellAcessorio = new PdfPCell(); Paragraph pAcessorio = new Paragraph(); pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess)); pAcessorio.add(new Phrase( (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "), fontConteudoTxt_acess)); cellAcessorio.addElement(pAcessorio); cellAcessorio.setColspan(2); cellAcessorio.setBorder(0); cellAcessorio.setPaddingBottom(4f); cellAcessorio.setPaddingTop(-2f); pTableAssinatura.addCell(cellAcessorio); PdfPCell cellLinhaAssina = new PdfPCell(); Paragraph pAssinatura = new Paragraph(); pAssinatura.add(new Paragraph("_________________________________", fontConteudo)); pAssinatura.add(new Paragraph(" Carimbo e Assinatura", fontConteudo)); pAssinatura.setAlignment(Element.ALIGN_CENTER); cellLinhaAssina.addElement(pAssinatura); cellLinhaAssina.setPaddingBottom(2f); cellLinhaAssina.setBorder(0); cellLinhaAssina.setPaddingTop(25f); pTableAssinatura.addCell(cellLinhaAssina); PdfPCell cellCambio = new PdfPCell(); Paragraph pCombio = new Paragraph(); pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt)); pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt)); cellCambio.addElement(pCombio); cellCambio.setBorder(0); cellCambio.setPaddingTop(-2f); cellCambio.setPaddingBottom(2f); pTableAssinatura.addCell(cellCambio); PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura); cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal)); // pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent()); // pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); } catch (BadElementException | IOException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return pTablePrincipal; }
From source file:Export.SeguroRoubo.java
public String criarDoc(String numApolice, String numCliente, RouboBean rb, Contrato c, String user, String arquivo) {//from w ww .ja v a2 s .c o m try { SimpleDateFormat sdf = new SimpleDateFormat("dd 'DE' MMMM 'DE' yyyy", new Locale("pt", "BR")); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = 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); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.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); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableSeguro = new PdfPTable(1); PdfPTable pTableCliente = new PdfPTable(1); PdfPTable pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("Formulario de SEguro Roubo".toUpperCase(), fontCorpoNGT); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); ClienteI ci = new ClienteI(numCliente); PdfPCell cellTituloTsbleSegurado = new PdfPCell( new Phrase("1 - Informaes Cliente".toUpperCase(), fontCorpoNG)); cellTituloTsbleSegurado.setBorder(0); Paragraph pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getNOMEL_(), fontCorpo)); pCl.add(new Phrase(ci.getNOME_(), fontCorpoN)); PdfPCell cellNome = new PdfPCell(new Phrase(pCl)); cellNome.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getENDERECOL_(), fontCorpo)); pCl.add(new Phrase(ci.getENDERECO_(), fontCorpoN)); PdfPCell cellEndereco = new PdfPCell(pCl); cellEndereco.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getNUNCLIENTEL_(), fontCorpo)); pCl.add(new Phrase(ci.getNUNCLIENTE_(), fontCorpoN)); PdfPCell cellNCliente = new PdfPCell(pCl); cellNCliente.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getPROFISSAOL_(), fontCorpo)); pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN)); PdfPCell cellProfissao = new PdfPCell(pCl); cellProfissao.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getLOCALTRABALHOL_(), fontCorpo)); pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN)); PdfPCell cellLocalTrabalho = new PdfPCell(pCl); cellLocalTrabalho.setBorder(0); pTableCliente.addCell(cellTituloTsbleSegurado); pTableCliente.addCell(cellNome); pTableCliente.addCell(cellEndereco); pTableCliente.addCell(cellNCliente); pTableCliente.addCell(cellProfissao); pTableCliente.addCell(cellLocalTrabalho); PdfPTable pTableDadosTitulo = new PdfPTable(1); PdfPCell cellDadosTitulo = new PdfPCell(new Phrase()); cellDadosTitulo.setBorder(0); Paragraph pInfoTitulo = new Paragraph("2 - Informaes do(s) Objecto (s) Segurado(s)".toUpperCase(), fontCorpoN); Paragraph pInfo1 = new Paragraph(" O Segurado: ".toUpperCase() + rb.getRoubo().getTipoEdificio(), fontCorpo); Paragraph pInfo2 = new Paragraph(" Endereo: ".toUpperCase() + rb.getRoubo().getEnderecoEdificio(), fontCorpo); cellDadosTitulo.addElement(pInfoTitulo); cellDadosTitulo.addElement(pInfo1); cellDadosTitulo.addElement(pInfo2); pTableDadosTitulo.addCell(cellDadosTitulo); PdfPCell cellSeguro = new PdfPCell(new Phrase()); cellSeguro.setBorder(0); Paragraph pSegTitulo = new Paragraph("3 - Informaes Montante Segurado".toUpperCase(), fontCorpoN); Paragraph pSeg1 = new Paragraph( " A Propriendade SEgurada: ......................................................... veja a especificao I" .toUpperCase(), fontCorpo); Paragraph pSeg2 = new Paragraph(" Periodo Do Seguro ".toUpperCase(), fontCorpo); Paragraph pSeg3 = new Paragraph(" - DE " + sdf.format(c.getDataInicio()) + " At " + sdf.format(c.getDataFim()) + " (16:00 Da DATA DE Epirao): ".toUpperCase(), fontCorpo); Paragraph pSeg4 = new Paragraph(" Data de Renovao: " + ((c.getDataRenovacao() == null) ? "" : sdf.format(c.getDataRenovacao()).toUpperCase()), fontCorpo); Paragraph pSeg5 = new Paragraph(" Primeiro premio: ".toUpperCase() + c.getPrimeiroPremio(), fontCorpo); Paragraph pSeg6 = new Paragraph(" Prmeio Anual: ".toUpperCase() + c.getPremioAnual(), fontCorpo); Paragraph pSeg7 = new Paragraph( "Ojectos/Limite de responsabilidade dedutvel/prmio/observao/natureza/Do Risco/valor segurado/preo excesso" .toUpperCase(), fontCorpo); Paragraph pSeg8 = new Paragraph(" ".toUpperCase(), fontCorpo); Paragraph pSeg9 = new Paragraph(" Prmio grosso:".toUpperCase(), fontCorpo); Paragraph pSeg10 = new Paragraph(" MeNor: ".toUpperCase(), fontCorpo); Paragraph pSeg11 = new Paragraph(" Adiciona: ".toUpperCase(), fontCorpo); Paragraph pSeg12 = new Paragraph(" Prmio Liquido Pagvel: ".toUpperCase(), fontCorpo); Paragraph pSeg13 = new Paragraph( " outras condies/memorando .......................................................... queira por favor vira a pgina " .toUpperCase(), fontCorpo); Paragraph pSegData = new Paragraph(" Data Em ".toUpperCase() + sdf.format(new Date()).toUpperCase(), fontCorpo); cellSeguro.addElement(pSegTitulo); cellSeguro.addElement(pSeg1); cellSeguro.addElement(pSeg2); cellSeguro.addElement(pSeg3); cellSeguro.addElement(pSeg4); cellSeguro.addElement(pSeg5); cellSeguro.addElement(pSeg6); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg7); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg9); cellSeguro.addElement(pSeg10); cellSeguro.addElement(pSeg11); cellSeguro.addElement(pSeg12); cellSeguro.addElement(pSeg13); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSegData); pTableSeguro.addCell(cellSeguro); PdfPTable pTableObs = new PdfPTable(1); PdfPCell cellObs = new PdfPCell(); cellObs.setBorder(0); Paragraph pObs = new Paragraph( "2.2 Especificao lidada e que faz parte de aplice de seguro contra Roubo N. 1" .toUpperCase(), fontCorpo); cellObs.addElement(pSeg8); cellObs.addElement(pSeg8); cellObs.setBorderWidthBottom(0.6f); cellObs.addElement(pObs); PdfPCell cellObs1 = new PdfPCell(); cellObs1.setBorder(0); Paragraph pObs1 = new Paragraph( "Sobre artigos domsticos e afetos pessoais incluindo mobilias e instalaes, a proprriedade do Seguro ou" + "ou em fiana ou sobre comisso do qual o Segurado responsavel enqunto estiver num edificio de contruo padro.", fontCorpo); cellObs1.addElement(pObs1); cellObs1.addElement(pSeg8); cellObs1.addElement(pSeg8); pTableObs.addCell(cellObs); pTableObs.addCell(cellObs1); PdfPTable pTableOjsSegurado = new PdfPTable(new float[] { 8, 40, 26, 26 }); pTableOjsSegurado.setWidthPercentage(90); PdfPTable pTableOjsSegurado1 = new PdfPTable(new float[] { 74, 26 }); pTableOjsSegurado1.setWidthPercentage(90); PdfPCell cellOjsSegurado1 = new PdfPCell(new Phrase("Quant.", fontCorpoNG)); PdfPCell cellOjsSegurado2 = new PdfPCell( new Phrase("Descrio de Propriedade".toUpperCase(), fontCorpoNG)); PdfPCell cellOjsSegurado3 = new PdfPCell( new Phrase("Modelo No/n DE Serie".toUpperCase(), fontCorpoNG)); PdfPCell cellOjsSegurado4 = new PdfPCell(new Phrase("Valor Segurado".toUpperCase(), fontCorpoNG)); cellOjsSegurado1.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado2.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado3.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado4.setHorizontalAlignment(Element.ALIGN_CENTER); pTableOjsSegurado.addCell(cellOjsSegurado1); pTableOjsSegurado.addCell(cellOjsSegurado2); pTableOjsSegurado.addCell(cellOjsSegurado3); pTableOjsSegurado.addCell(cellOjsSegurado4); Double valortotal = 0.0; for (Roubo r : rb.getInfo()) { cellOjsSegurado1 = new PdfPCell(new Phrase(r.getQuantidade(), fontCorpo)); cellOjsSegurado2 = new PdfPCell(new Phrase(r.getDescricao(), fontCorpo)); cellOjsSegurado3 = new PdfPCell(new Phrase(r.getModelo(), fontCorpo)); cellOjsSegurado4 = new PdfPCell(new Phrase(r.getValor(), fontCorpo)); valortotal += Double.valueOf(r.getValor()); cellOjsSegurado1.setHorizontalAlignment(Element.ALIGN_LEFT); cellOjsSegurado2.setHorizontalAlignment(Element.ALIGN_LEFT); cellOjsSegurado3.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado4.setHorizontalAlignment(Element.ALIGN_LEFT); pTableOjsSegurado.addCell(cellOjsSegurado1); pTableOjsSegurado.addCell(cellOjsSegurado2); pTableOjsSegurado.addCell(cellOjsSegurado3); pTableOjsSegurado.addCell(cellOjsSegurado4); } PdfPCell cellOjs1Segurado1 = new PdfPCell(new Phrase( "Somatrio ----------------------------------------------------------------------------------------------" .toUpperCase(), fontCorpo)); cellOjs1Segurado1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellOjs1Segurado2 = new PdfPCell(new Phrase(valortotal + "", fontCorpo)); cellOjs1Segurado2.setHorizontalAlignment(Element.ALIGN_LEFT); pTableOjsSegurado1.addCell(cellOjs1Segurado1); pTableOjsSegurado1.addCell(cellOjs1Segurado2); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas".toUpperCase(), fontCorpoN)); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("____________________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("____________________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP)); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP)); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); // File ff= new File("Documentos\\"+user+"\\Seguro Roubo\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Roubo "+sdf1.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Roubo/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Roubo " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Roubo/" + "Formulario Seguro Roubo " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableCliente); documento.add(pTableNull); documento.add(pTableDadosTitulo); documento.add(pTableNull); documento.add(pTableSeguro); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); if (rb.getInfo().size() >= 10) { documento.newPage(); } documento.add(pTableObs); documento.add(pTableOjsSegurado); documento.add(pTableOjsSegurado1); documento.close(); // PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // printPdf.print(); } 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 reString; }
From source file:ExternalNonFormClasses.PDFEnator.java
public PdfPTable writeHeaders(Font font) { PdfPTable pdftable = new PdfPTable(setTableDimensions()); pdftable.setTotalWidth(480);// w w w. ja v a2 s .c om for (int a = 0; a < this.tableHeaderData.size(); a++) { System.out.println("Header #" + a); PdfPCell cell1 = new PdfPCell(new Paragraph(this.tableHeaderData.get(a), font)); cell1.setPaddingBottom(5); cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); pdftable.addCell(cell1); } return pdftable; }
From source file:ExternalNonFormClasses.PDFEnator.java
public void createPDF() { try {/*from w w w . j a v a 2 s.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 ww w . j a v a 2s . com 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:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBorderTop(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);/* ww w. ja v a 2 s. co m*/ chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.TOP); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellNoBorder(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);/* w w w .j av a 2s . c om*/ chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.NO_BORDER); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCell(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);// w w w .j a v a 2s. c om chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.LEFT); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBox(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);// w w w .ja v a 2s .c o m chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.BOX); return cell; }