List of usage examples for com.itextpdf.text PageSize A4
Rectangle A4
To view the source code for com.itextpdf.text PageSize A4.
Click Source Link
From source file:es.clinica.veterinaria.facturas.FacturaPdf.java
public void createPdf() { try {/*from w ww . j av a2s . co m*/ PdfWriter docWriter = null; initializeFonts(); FacturaDAO facturaDao = new FacturaDAO(); document = new Document(PageSize.A4); String fecha = new SimpleDateFormat("yyyy-MM-dd").format(factura.getFecha()); String sfactura = getDirectorio().toString() + "/factura-" + fecha + "-" + factura.getNumero() + ".pdf"; System.out.println("Directorio factura: " + sfactura); docWriter = PdfWriter.getInstance(document, new FileOutputStream(sfactura)); document.open(); PdfContentByte cb = docWriter.getDirectContent(); addMetaData(document); addLogo(document); generateHeader(document, cb); addTitlePage(document); document.add(createTable()); document.close(); factura.setRuta("../facturaspdf/factura-" + fecha + "-" + factura.getNumero() + ".pdf"); facturaDao.updatePDF(factura); System.out.println("Documento cerrado"); } catch (Exception e) { e.printStackTrace(); } }
From source file:es.sm2.openppm.front.utils.DocumentUtils.java
License:Open Source License
/** * Create PDF for Control Change/* ww w . j a v a2 s .c om*/ * @param idioma * @param project * @param change * @param preparedBy * @return * @throws DocumentException * @throws LogicException */ public static byte[] toPdf(ResourceBundle idioma, Project project, Changecontrol change, Employee preparedBy, final Image headerImg, final Image footerImg) throws DocumentException, LogicException { if (change == null) { throw new DocumentException("No change control found."); } if (preparedBy == null || preparedBy.getContact() == null) { throw new UserSendingException(); } Document document = new Document(PageSize.A4); document.setMargins(70F, 70F, 38F, 38F); // Total Height: 842pt, Total Width: 595pt byte[] file = null; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @SuppressWarnings("unused") PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream); document.open(); Font fontHeader = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD); Font fontCell = new Font(FontFamily.TIMES_ROMAN, 9); Font tituloFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.BOLD); document.add(new Paragraph(" ", tituloFont)); document.add(new Paragraph(" ", tituloFont)); document.add(new Paragraph(" ", fontHeader)); Paragraph title = new Paragraph(idioma.getString("change_request").toUpperCase(), tituloFont); title.setAlignment(Paragraph.ALIGN_CENTER); document.add(title); // Header Table // Project info PdfPTable tableHeader = new PdfPTable(3); tableHeader.setWidthPercentage(100); tableHeader.setSpacingBefore(10); tableHeader.setSpacingAfter(15); int[] colWidth = new int[3]; colWidth[0] = 40; colWidth[1] = 30; colWidth[2] = 30; tableHeader.setWidths(colWidth); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.project_name"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.prepared_by"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell(prepareHeaderCell(idioma.getString("change_request.date"), fontHeader, 1F, 1F, 0F, 1F)); tableHeader.addCell(prepareCell(project.getProjectName() + " / " + project.getAccountingCode(), fontCell, 0F, 0F, 0F, 1F)); tableHeader.addCell(prepareCell(preparedBy.getContact().getFullName(), fontCell, 0F, 0F, 0F, 1F)); tableHeader.addCell(prepareCell(DateUtil.format(idioma, new Date()), fontCell, 0F, 1F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.customer"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.contact_name"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.customer_type"), fontHeader, 1F, 1F, 0F, 1F)); tableHeader.addCell(prepareCell(project.getCustomer() != null ? project.getCustomer().getName() : "", fontCell, 0F, 0F, 0F, 1F)); tableHeader.addCell(prepareCell((project.getCustomer() != null ? project.getCustomer().getName() : "-"), fontCell, 0F, 0F, 0F, 1F)); Customertype cusType = (project.getCustomer() != null ? project.getCustomer().getCustomertype() : null); tableHeader.addCell(prepareCell(cusType == null ? "" : cusType.getName(), fontCell, 0F, 1F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.business_manager"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.project_manager"), fontHeader, 1F, 0F, 0F, 1F)); tableHeader.addCell( prepareHeaderCell(idioma.getString("change_request.originator"), fontHeader, 1F, 1F, 0F, 1F)); Employee bm = project.getEmployeeByFunctionalManager(); Employee pm = project.getEmployeeByProjectManager(); tableHeader.addCell(prepareCell(bm == null ? "" : bm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F)); tableHeader.addCell(prepareCell(pm == null ? "" : pm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F)); tableHeader.addCell(prepareCell(change.getOriginator(), fontCell, 0F, 1F, 1F, 1F)); document.add(tableHeader); // Change Information document.add(new Paragraph(idioma.getString("change_information"))); PdfPTable tableInfo = new PdfPTable(1); tableInfo.setWidthPercentage(100); tableInfo.setSpacingBefore(10); tableInfo.setSpacingAfter(15); tableInfo.addCell(prepareHeaderCell(idioma.getString("change.change_type"), fontHeader, 1F, 1F, 0F, 1F)); tableInfo.addCell(prepareCell(change.getChangetype().getDescription(), fontCell, 0F, 1F, 0F, 1F)); String priorityDesc = ""; if (change.getPriority().equals('H')) priorityDesc = idioma.getString("change.priority.high"); if (change.getPriority().equals('N')) priorityDesc = idioma.getString("change.priority.normal"); if (change.getPriority().equals('L')) priorityDesc = idioma.getString("change.priority.low"); tableInfo.addCell(prepareHeaderCell(idioma.getString("change.priority"), fontHeader, 1F, 1F, 0F, 1F)); tableInfo.addCell(prepareCell(priorityDesc, fontCell, 0F, 1F, 0F, 1F)); tableInfo.addCell(prepareHeaderCell(idioma.getString("change.desc"), fontHeader, 1F, 1F, 0F, 1F)); tableInfo.addCell(prepareCell(change.getDescription(), fontCell, 0F, 1F, 0F, 1F)); tableInfo.addCell( prepareHeaderCell(idioma.getString("change.recommended_solution"), fontHeader, 1F, 1F, 0F, 1F)); tableInfo.addCell(prepareCell(change.getRecommendedSolution(), fontCell, 0F, 1F, 1F, 1F)); PdfPTable tableSubInfo = new PdfPTable(3); tableSubInfo.setWidthPercentage(100); //TODO MIGRACION tableSubInfo.addCell(prepareSubCell(idioma.getString("change.wbs_node"), fontHeader)); tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_effort"), fontHeader)); tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_cost"), fontHeader)); tableSubInfo.addCell( prepareSubCell((change.getWbsnode() != null ? change.getWbsnode().getName() : ""), fontCell)); tableSubInfo.addCell(prepareSubCell( (change.getEstimatedEffort() != null ? String.valueOf(change.getEstimatedEffort()) : ""), fontCell)); tableSubInfo.addCell(prepareSubCell( (change.getEstimatedCost() != null ? ValidateUtil.toCurrency(change.getEstimatedCost()) : ""), fontCell)); PdfPCell subTable = new PdfPCell(tableSubInfo); subTable.setBorderWidth(1F); tableInfo.addCell(subTable); tableInfo.addCell(prepareHeaderCell(idioma.getString("change.impact_desc"), fontHeader, 1F, 1F, 0F, 1F)); tableInfo.addCell(prepareCell(change.getImpactDescription(), fontCell, 0F, 1F, 1F, 1F)); document.add(tableInfo); document.add(new Paragraph(idioma.getString("change.resolution"))); PdfPTable tableResolution = new PdfPTable(1); tableResolution.setWidthPercentage(100); tableResolution.setSpacingBefore(10); tableResolution.setSpacingAfter(15); tableResolution .addCell(prepareHeaderCell(idioma.getString("change.resolution"), fontHeader, 1F, 1F, 0F, 1F)); tableResolution.addCell( prepareCell((change.getResolution() != null && change.getResolution() ? idioma.getString("yes") : idioma.getString("no")), fontCell, 0F, 1F, 0F, 1F)); tableResolution .addCell(prepareHeaderCell(idioma.getString("change.resolution_date"), fontHeader, 1F, 1F, 0F, 1F)); tableResolution.addCell( prepareCell(DateUtil.format(idioma, change.getResolutionDate()), fontCell, 0F, 1F, 0F, 1F)); tableResolution.addCell( prepareHeaderCell(idioma.getString("change.resolution_reason"), fontHeader, 1F, 1F, 0F, 1F)); tableResolution.addCell(prepareCell(change.getResolutionReason(), fontCell, 0F, 1F, 1F, 1F)); document.add(tableResolution); document.close(); try { PdfReader reader = new PdfReader(outputStream.toByteArray()); PdfStamper stamper = new PdfStamper(reader, outputStream); int numPag = reader.getNumberOfPages(); for (int i = 1; i <= reader.getNumberOfPages(); i++) { setHeaderFooter(i, numPag, headerImg, footerImg, reader, stamper, idioma); } stamper.close(); } catch (IOException e) { e.printStackTrace(); } file = outputStream.toByteArray(); return file; }
From source file:essencialles.modelos.relatorio.tipos.MaisVendidos.java
@Override public void run() { try {//w w w. j a va 2 s. co m //criao do PDF Document doc = new Document(PageSize.A4, 72, 72, 72, 72); OutputStream saida = new FileOutputStream(this.caminho); PdfWriter.getInstance(doc, saida); doc.open(); try { //logomarca Image img = Image.getInstance("src/views/img/logomarca.png"); img.setAlignment(Element.ALIGN_CENTER); doc.add(img); } catch (BadElementException | IOException ex) { throw new RuntimeException(ex); } //paragrafo Paragraph paragrafo = new Paragraph("Relatrio de Produtos Mais Vendidos"); paragrafo.setSpacingAfter(50); paragrafo.setSpacingBefore(15); paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD)); paragrafo.setAlignment(Element.ALIGN_CENTER); doc.add(paragrafo); /*tabela PdfPTable tabela = new PdfPTable(9); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos")); header.setColspan(9); tabela.addCell(header); tabela.addCell("Codigo"); tabela.addCell("Nome"); tabela.addCell("Marca"); tabela.addCell("Preo"); tabela.addCell("Custo"); tabela.addCell("Cor"); tabela.addCell("Descrio"); tabela.addCell("Peso"); tabela.addCell("Disponibilidade"); tabela.addCell("Validade"); adicionar linhas da tabela. for (Produto p : produtos) { String cod = p.getCod_produto() + ""; String nome = p.getNome(); String marca = p.getMarca(); String preco = p.getPreco() + ""; String custo = p.getCusto() + ""; String cor = p.getCor(); String descricao = p.getDescricao(); String peso = p.getPeso(); String disponibilidade = p.getDisponibilidade(); String validade = p.getValidade() + ""; }*/ try { saida.flush(); } catch (IOException ex) { throw new RuntimeException(ex); } doc.close(); try { saida.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } catch (FileNotFoundException | DocumentException ex) { throw new RuntimeException(ex); } }
From source file:essencialles.modelos.relatorio.tipos.ProdutosTodos.java
@Override public void run() { try {/*from w w w.j a v a2 s .c o m*/ //criao do PDF Document doc = new Document(PageSize.A4, 72, 72, 72, 72); OutputStream saida = new FileOutputStream(this.caminho); PdfWriter.getInstance(doc, saida); doc.open(); try { //logomarca Image img = Image.getInstance("src/views/img/logomarca.png"); img.setAlignment(Element.ALIGN_CENTER); doc.add(img); } catch (BadElementException | IOException ex) { throw new RuntimeException(ex); } //paragrafo Paragraph paragrafo = new Paragraph("Relatrio de Produtos"); paragrafo.setSpacingAfter(50); paragrafo.setSpacingBefore(15); paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD)); paragrafo.setAlignment(Element.ALIGN_CENTER); doc.add(paragrafo); /*tabela PdfPTable tabela = new PdfPTable(9); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos")); header.setColspan(9); tabela.addCell(header); tabela.addCell("Codigo"); tabela.addCell("Nome"); tabela.addCell("Marca"); tabela.addCell("Preo"); tabela.addCell("Custo"); tabela.addCell("Cor"); tabela.addCell("Descrio"); tabela.addCell("Peso"); tabela.addCell("Disponibilidade"); tabela.addCell("Validade"); adicionar linhas da tabela. for (ProdutoModelo p : produtos) { String cod = p.getCod_produto() + ""; String nome = p.getNome(); String marca = p.getMarca(); String preco = p.getPreco() + ""; String custo = p.getCusto() + ""; String cor = p.getCor(); String descricao = p.getDescricao(); String peso = p.getPeso(); String disponibilidade = p.getDisponibilidade(); String validade = p.getValidade() + ""; }*/ try { saida.flush(); } catch (IOException ex) { throw new RuntimeException(ex); } doc.close(); try { saida.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } catch (FileNotFoundException | DocumentException ex) { throw new RuntimeException(ex); } }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.PdfGenerator.java
License:Open Source License
private int createPdf(OutputStream os, int indexSize, IProgressMonitor monitor) throws DocumentException, IOException { Document document = new Document(PageSize.A4, MARGIN_LEFT, MARGIN_RIGHT, MARGIN_UP, MARGIN_DOWN); PdfWriter writer = PdfWriter.getInstance(document, os); writer.setStrictImageSequence(true); writer.setLinearPageMode();// used to reorder page; // writer.setPdfVersion(PdfWriter.PDF_VERSION_1_6); ChapterSectionTOC event = new ChapterSectionTOC(); writer.setPageEvent(event);// w w w . ja v a 2s. c o m event.pagenumber = rcf.startingPageNumber(); writer.setBoxSize("art", new Rectangle(MARGIN_LEFT, 0, PageSize.A4.getWidth() - MARGIN_RIGHT, FOOTER_HEIGHT)); monitor.beginTask("Generating Report", 100); document.open(); rcf.buildContent(writer, document, new SubProgressMonitor(monitor, 85)); if (rcf.buildIndex()) { document.newPage(); event.setIndex(true); int toc = writer.getPageNumber(); buildIndex(writer, document); document.newPage(); monitor.worked(10); int total = writer.reorderPages(null); int tocLenght = total - toc + 1; int[] order = new int[total]; order[0] = 1; for (int i = 0; i < tocLenght; i++) { order[i + 1] = toc + i; } for (int i = 2; i < toc; i++) { order[i + tocLenght - 1] = i; } writer.reorderPages(order); document.close(); monitor.worked(5); return tocLenght; } return -1; }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildFirstPage(PdfWriter writer, Document document) throws DocumentException { Paragraph firstPageTitleParagraph = new Paragraph(getDocumentTitle(), FIRST_PAGE_TITLE); firstPageTitleParagraph.setAlignment(Element.ALIGN_CENTER); firstPageTitleParagraph.setSpacingAfter(Utilities.millimetersToPoints(50)); document.add(firstPageTitleParagraph); Paragraph firstPageProjectNameParagraph = new Paragraph(getProjectName(), FIRST_PAGE_PRJ_NAME); firstPageProjectNameParagraph.setAlignment(Element.ALIGN_CENTER); firstPageProjectNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageProjectNameParagraph); Paragraph firstPageAuthorNameParagraph = new Paragraph(getReportAuthor(), FIRST_PAGE_AUTHOR); firstPageAuthorNameParagraph.setAlignment(Element.ALIGN_CENTER); firstPageAuthorNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageAuthorNameParagraph); Paragraph firstPageOrganizationParagraph = new Paragraph(getReportIstitution(), FIRST_PAGE_ORGANIZ); firstPageOrganizationParagraph.setAlignment(Element.ALIGN_CENTER); firstPageOrganizationParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageOrganizationParagraph); Paragraph firstPageDateParagraph = new Paragraph(getDate(), FIRST_PAGE_DATE); firstPageDateParagraph.setAlignment(Element.ALIGN_CENTER); firstPageDateParagraph.setSpacingAfter(Utilities.millimetersToPoints(40)); document.add(firstPageDateParagraph); String[] phrases = { "This document has been generated by STS-Tool", "http://www.sts-tool.eu" }; Paragraph firstPageLastLineParagraph = new Paragraph(phrases[0], FIRST_PAGE_LAST_LINE); for (int i = 1; i < phrases.length; i++) { firstPageLastLineParagraph.add(Chunk.NEWLINE); firstPageLastLineParagraph.add(new Phrase(phrases[i], FIRST_PAGE_LAST_LINE)); }/*from w ww . jav a2s .com*/ firstPageLastLineParagraph.setAlignment(Element.ALIGN_CENTER); document.add(firstPageLastLineParagraph); if (footerImage != null) { footerImage.setAbsolutePosition((PageSize.A4.getWidth() / 2) - (footerImage.getPlainWidth() / 2), 50); document.add(footerImage); } }
From source file:Excel.pdfsJavaGenerador.java
public void run() { Document documento = new Document(); documento.setPageSize(PageSize.A4.rotate()); int i = 1;//from w ww . j a v a2 s . c o m String arch = periodo + "_Iva Ventas.pdf"; File fich = new File(arch); FileOutputStream fichero; try { pdfsJavaGenerador pdf; ArrayList listado = new ArrayList(); String sql = "select * from ivaventas where periodo='" + periodo + "' order by numero"; Transaccionable tra = new ConeccionLocal(); ResultSet rs = tra.leerConjuntoDeRegistros(sql); while (rs.next()) { pdf = new pdfsJavaGenerador(); pdf.setComprobante(rs.getString("comprobante")); pdf.setFecha(rs.getString("fecha")); pdf.setNumeroFactura(rs.getString("numero")); pdf.setRazonSocial(rs.getString("cliente")); pdf.setCondicionIva(rs.getString("condicion")); pdf.setCuit(rs.getString("cuit")); pdf.setNeto(rs.getString("neto")); pdf.setIva(rs.getString("iva")); pdf.setTotal(rs.getString("total")); listado.add(pdf); } rs.close(); Integer totalItems = listado.size(); Integer totalPaginas = totalItems / 46; Integer contadorPaginas = 1; totalPaginas = totalPaginas + 1; System.out.println(" items " + totalItems + " paginas " + totalPaginas); fichero = new FileOutputStream(arch); PdfWriter writer = PdfWriter.getInstance(documento, fichero); documento.open(); //writer.addPageDictEntry(PdfName.ROTATE,PdfPage.SEASCAPE); writer.addPageDictEntry(PdfName.ROTATE, null); PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 12); cb.beginText(); //cb.setTextMatrix(250,820); //cb.showText("Subdiario de IVA Ventas"); cb.setFontAndSize(bf, 10); cb.setTextMatrix(20, 480); cb.showText("Periodo " + periodo); //cb.setTextMatrix(750,550); //cb.showText("Hoja "+contadorPaginas+" de "+totalPaginas); int renglon = 460; String vencimiento; String descripcion; String monto; String recargo; String total; String totalFinal; Double tot = 0.00; String razonSocial; int itt = 0; //aca empieza la iteracion //encabezados bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 8); cb.setTextMatrix(20, renglon); cb.showText("Cbte"); cb.setTextMatrix(50, renglon); cb.showText("Fecha"); cb.setTextMatrix(90, renglon); cb.showText("Nro Factura"); cb.setTextMatrix(150, renglon); cb.showText("Cliente"); cb.setTextMatrix(500, renglon); //tot=saldo.getCantidad() * saldo.getPrecioUnitario(); cb.showText("Cond"); cb.setTextMatrix(540, renglon); cb.showText("C.U.I.T."); cb.setTextMatrix(610, renglon); cb.showText("Neto"); cb.setTextMatrix(660, renglon); cb.showText("I.V.A."); cb.setTextMatrix(700, renglon); cb.showText("Imp. Int."); cb.setTextMatrix(760, renglon); cb.showText("Total"); renglon = renglon - 20; //fin encabezados bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 6); Iterator itl = listado.listIterator(); //vencimiento="Esta cotizacin tendr vigencia 30 das "; Double montoCIva = 0.00; Double descuento = 0.00; Double descUnitario = 0.00; Double descTotal = 0.00; Double montoCIvaTotal = 0.00; Double descuentoTotal = 0.00; Double descUnitarioTotal = 0.00; Double descTotalTotal = 0.00; String descripcionArt = null; while (itl.hasNext()) { pdf = (pdfsJavaGenerador) itl.next(); //vencimiento=saldo.getVencimientoString(); /* descripcion="Numero Resumen de cta "; montoCIva=saldo.getPrecioUnitario() * 1.21; monto=Numeros.ConvertirNumero(montoCIva); recargo="10%"; total="nada"; */ //recargo=String.valueOf(saldo.getRecargo()); //tot=tot + saldo.getTotal(); //total=String.valueOf(saldo.getTotal()); cb.setTextMatrix(20, renglon); cb.showText(pdf.getComprobante()); cb.setTextMatrix(45, renglon); cb.showText(pdf.getFecha()); cb.setTextMatrix(90, renglon); cb.showText(pdf.getNumeroFactura()); cb.setTextMatrix(150, renglon); razonSocial = pdf.getRazonSocial(); cb.showText(razonSocial); cb.setTextMatrix(500, renglon); cb.showText(pdf.getCondicionIva()); cb.setTextMatrix(540, renglon); cb.showText(pdf.getCuit()); cb.setTextMatrix(600, renglon); if (pdf.getComprobante().equals("N.C.")) { String neto = pdf.getNeto(); String iva = pdf.getIva(); String totalP = pdf.getTotal(); pdf.setNeto("-" + neto.trim()); pdf.setIva("-" + iva.trim()); pdf.setTotal("-" + totalP.trim()); } montoCIva = montoCIva + Numeros.ConvertirStringADouble(pdf.getNeto()); descuento = descuento + Numeros.ConvertirStringADouble(pdf.getIva()); descTotal = descTotal + Numeros.ConvertirStringADouble(pdf.getTotal()); cb.showText(pdf.getNeto()); cb.setTextMatrix(650, renglon); cb.showText(pdf.getIva()); cb.setTextMatrix(710, renglon); cb.showText("0.00"); cb.setTextMatrix(750, renglon); cb.showText(pdf.getTotal()); //descuento=descuento+saldo.getDescuento(); renglon = renglon - 10; if (renglon < 30) { bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 7); cb.setTextMatrix(550, renglon); cb.showText("Subtotal:"); cb.setTextMatrix(600, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(montoCIva)); cb.setTextMatrix(650, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descuento)); cb.setTextMatrix(710, renglon); cb.showText("0.00"); cb.setTextMatrix(750, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descTotal)); montoCIvaTotal = montoCIvaTotal + montoCIva; descuentoTotal = descuentoTotal + descuento; descTotalTotal = descTotalTotal + descTotal; descuento = 0.00; descTotal = 0.00; montoCIva = 0.00; renglon = 460; cb.endText(); documento.newPage(); documento.setPageSize(PageSize.A4.rotate()); cb.beginText(); contadorPaginas++; cb.setFontAndSize(bf, 12); //cb.setTextMatrix(250,820); //cb.showText("Subdiario de IVA Ventas"); cb.setFontAndSize(bf, 10); cb.setTextMatrix(20, 480); cb.showText("Periodo " + periodo); //cb.setTextMatrix(750,550); //cb.showText("Hoja "+contadorPaginas+" de "+totalPaginas); //aca empieza la iteracion //encabezados bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 8); cb.setTextMatrix(20, renglon); cb.showText("Cbte"); cb.setTextMatrix(50, renglon); cb.showText("Fecha"); cb.setTextMatrix(90, renglon); cb.showText("Nro Factura"); cb.setTextMatrix(150, renglon); cb.showText("Cliente"); cb.setTextMatrix(500, renglon); //tot=saldo.getCantidad() * saldo.getPrecioUnitario(); cb.showText("Cond"); cb.setTextMatrix(540, renglon); cb.showText("C.U.I.T."); cb.setTextMatrix(610, renglon); cb.showText("Neto"); cb.setTextMatrix(660, renglon); cb.showText("I.V.A."); cb.setTextMatrix(700, renglon); cb.showText("Imp. Int."); cb.setTextMatrix(760, renglon); cb.showText("Total"); renglon = renglon - 20; //fin encabezados bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 6); } } bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 7); cb.setTextMatrix(540, renglon); cb.showText("Subtotal:"); cb.setTextMatrix(600, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(montoCIva)); cb.setTextMatrix(650, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descuento)); cb.setTextMatrix(710, renglon); cb.showText("0.00"); cb.setTextMatrix(750, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descTotal)); renglon = renglon - 10; montoCIvaTotal = montoCIvaTotal + montoCIva; descuentoTotal = descuentoTotal + descuento; descTotalTotal = descTotalTotal + descTotal; cb.setTextMatrix(540, renglon); cb.showText("Total:"); cb.setTextMatrix(600, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(montoCIvaTotal)); cb.setTextMatrix(650, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descuentoTotal)); cb.setTextMatrix(710, renglon); cb.showText("0.00"); cb.setTextMatrix(750, renglon); cb.showText(Numeros.ConvetirNumeroDosDigitos(descTotalTotal)); descuento = 0.00; descTotal = 0.00; montoCIva = 0.00; cb.endText(); documento.close(); File f = new File(arch); if (f.exists()) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + arch); } int confirmacion = 0; /* if(doc.getArchivo().isEmpty()){ }else{ confirmacion=JOptionPane.showConfirmDialog(null, "DESEA NOTIFICAR POR MAIL?"); if(confirmacion==0){ //JOptionPane.showMessageDialog(null,"acepto"); } } */ System.out.println("eligio " + confirmacion); } catch (FileNotFoundException ex) { Logger.getLogger(pdfsJavaGenerador.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(pdfsJavaGenerador.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(pdfsJavaGenerador.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(pdfsJavaGenerador.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.CertificadoCargaMaritima.java
public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user, String moeda, String arquivo) { try {/*w w w.j av a2 s.c o m*/ SimpleDateFormat sdf = 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, 9f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5.5f, Font.ITALIC); 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 pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("CErtificado Seguro de Carga Maritima".toUpperCase(), fontCorpoNG); pTitulo.add(new Phrase("\nMARINE CARGO CERTIFICATE", fontUK)); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 }); PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 }); PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 }); PdfPCell cellCorpopUm = new PdfPCell(); cellCorpopUm.setBorder(0); PdfPCell cellCorpopDois1 = new PdfPCell(); cellCorpopDois1.setBorder(0); PdfPCell cellCorpopDois2 = new PdfPCell(); cellCorpopDois2.setBorder(0); PdfPCell cellCorpopTres = new PdfPCell(); cellCorpopTres.setBorder(0); Paragraph pCorpoUm1 = new Paragraph( "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN); pCorpoUm1.add( new Phrase("\ncertificate OF insurance issued under contract open No.".toUpperCase(), fontUK)); Paragraph pCorpoUm2 = new Paragraph("mbito da cobertura: ".toUpperCase(), fontCorpoN); pCorpoUm2.add(new Phrase("\nSCOPE OF COVER", fontUK)); Paragraph pCorpoUm3 = new Paragraph( "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de", fontCorpo); pCorpoUm3.add(new Phrase( "\nTHIS IS TO CERTIFY THAT THE COMPANY HAS INSURED THE UNDER MENTIONED GOODS FOR THE VOYGE (S) AND VALUE (S) STATED ON BEHALF OF", fontUK)); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); cellCorpopUm.addElement(pCorpoUm3); pTableCorpoUm.addCell(cellCorpopUm); Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo); pCorpoDois11.add(new Phrase("\nMARINE RATE", fontUK)); Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo); pCorpoDois12.add(new Phrase("\nWAR RATE", fontUK)); cellCorpopDois1.addElement(pCorpoDois11); cellCorpopDois1.addElement(pCorpoDois12); pTableCorpoDois.addCell(cellCorpopDois1); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo); pCorpoDois21.add(new Phrase("\nDEBIT NOTE NO", fontUK)); Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo); pCorpoDois22.add(new Phrase("\nGROSS PREMIUM", fontUK)); cellCorpopDois2.addElement(pCorpoDois21); cellCorpopDois2.addElement(pCorpoDois22); pTableCorpoDois.addCell(cellCorpopDois2); Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo); pCorpoTres1.add(new Phrase("\nSuperintendent RATE".toUpperCase(), fontUK)); Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo); pCorpoTres2.add(new Phrase("\nINLANDTraffic Rate", fontUK)); Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo); pCorpoTres3.add(new Phrase("\nTOTAL RATE", fontUK)); Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo); pCorpoTres4.add(new Phrase("\nInsured".toUpperCase(), fontUK)); Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: " + cm.getCargaMaritima().getFormaEnvio(), fontCorpo); pCorpoTres5.add(new Phrase("\nMODE OF CONVEYANCE", fontUK)); //Paragraph pCorpoTres6_1 = new Paragraph("Medadoria Assegurada: ",fontCorpo); Paragraph pCorpoTres6 = new Paragraph("De " + cm.getCargaMaritima().getPaisOrigem() + " Para: " + cm.getCargaMaritima().getPaisDestino(), fontCorpo); pCorpoTres6.add(new Phrase("\nFROM TO", fontUK)); Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo); pCorpoTres7.add(new Phrase("\nINTEREST", fontUK)); Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo); pCorpoTres8.add(new Phrase("\nINSURED VALUE", fontUK)); Paragraph pCorpoTres9 = new Paragraph( "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN); pCorpoTres9.add(new Phrase( "\nCONDITIONS : Subject to the following clsulas and warranteis (SEE APPENDICIX A)", fontUK)); Paragraph pCorpoTres10 = new Paragraph( "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato NICOM SEGUROS STP" + " para ser feita a vistoria (Por favor volte).", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn the event of loss or damage for which company is presumed to be liable, immediate resquest for survey must be made to NICON SEGUROS STP (PLEASE TURN OVER).", fontUK)); Paragraph pCorpoTres11 = new Paragraph( "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado" + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn case of loss or damage this certificate, must be annexed to the claim note accompaneid by the repost, original bill of landing, true copy" + " or original invoice and any other relevant documenent.", fontUK)); Paragraph pCorpoTres12 = new Paragraph(); Phrase p1 = new Phrase("Nota: ", fontCorpoN); Phrase p2 = new Phrase( "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido", fontCorpo); Phrase p3 = new Phrase( "\nThe Company undertakes to issue a policy covering the good described herein on request.", fontUK); pCorpoTres12.add(p1); pCorpoTres12.add(p2); pCorpoTres12.add(p3); cellCorpopTres.addElement(pCorpoTres1); cellCorpopTres.addElement(pCorpoTres2); cellCorpopTres.addElement(pCorpoTres3); cellCorpopTres.addElement(pCorpoTres4); cellCorpopTres.addElement(pCorpoTres5); //cellCorpopTres.addElement(pCorpoTres6_1); cellCorpopTres.addElement(pCorpoTres6); cellCorpopTres.addElement(pCorpoTres7); cellCorpopTres.addElement(pCorpoTres8); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres9); cellCorpopTres.addElement(pCorpoTres10); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres11); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres12); pTableCorpoTres.addCell(cellCorpopTres); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); Paragraph pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Assinaturas", fontCorpoN)); pUK.add(new Phrase("Signature", fontUK)); PdfPCell cellAssinatora = new PdfPCell(pUK); 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); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Pela NICON SEGUROS STP", fontCorpoN)); pUK.add(new Phrase("For NICON SEGUROS STP", fontUK)); PdfPCell celllinha11 = new PdfPCell(pUK); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("O Segurado", fontCorpoN)); pUK.add(new Phrase("Insured", fontUK)); PdfPCell celllinha21 = new PdfPCell(pUK); 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 f = new File(arquivo + "/" + user + "/Seguro Carga Maritima/"); f.mkdirs(); String Ddata = sdf.format(new Date()); f = new File(f.getAbsoluteFile() + "/" + "Certificado Carga Maritima " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Carga Maritima/" + "Certificado Carga Maritima " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); 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(pTableNull); documento.add(pTableCorpoUm); documento.add(pTableNull); documento.add(pTableCorpoDois); documento.add(pTableCorpoTres); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.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:Export.CertificadoMaritimo.java
public String criarDoc(String numApolice, String numCliente, MaritimoBean mb, Contrato c, String user, String moeda, String arquivo) { try {/*from w w w . j a v a 2s .c om*/ SimpleDateFormat sdf = 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, 9f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = 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 pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("CErtificado Seguro de Maritimo".toUpperCase(), fontCorpoNG); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 }); PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 }); PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 }); PdfPCell cellCorpopUm = new PdfPCell(); cellCorpopUm.setBorder(0); PdfPCell cellCorpopDois1 = new PdfPCell(); cellCorpopDois1.setBorder(0); PdfPCell cellCorpopDois2 = new PdfPCell(); cellCorpopDois2.setBorder(0); PdfPCell cellCorpopTres = new PdfPCell(); cellCorpopTres.setBorder(0); Paragraph pCorpoUm1 = new Paragraph( "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN); Paragraph pCorpoUm2 = new Paragraph("Abimto de Cortura: ".toUpperCase(), fontCorpoN); Paragraph pCorpoUm3 = new Paragraph( "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de", fontCorpo); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); cellCorpopUm.addElement(pCorpoUm3); pTableCorpoUm.addCell(cellCorpopUm); Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo); Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo); cellCorpopDois1.addElement(pCorpoDois11); cellCorpopDois1.addElement(pCorpoDois12); pTableCorpoDois.addCell(cellCorpopDois1); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo); Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo); cellCorpopDois2.addElement(pCorpoDois21); cellCorpopDois2.addElement(pCorpoDois22); pTableCorpoDois.addCell(cellCorpopDois2); Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo); Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo); Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo); Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo); Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: ", fontCorpo); Paragraph pCorpoTres6 = new Paragraph("De Para: ", fontCorpo); Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo); Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo); Paragraph pCorpoTres9 = new Paragraph( "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN); Paragraph pCorpoTres10 = new Paragraph( "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato NICOM SEGUROS STP" + " para ser feita a vistoria (Por favor volte).", fontCorpo); Paragraph pCorpoTres11 = new Paragraph( "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado" + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.", fontCorpo); Paragraph pCorpoTres12 = new Paragraph(); Phrase p1 = new Phrase("Nota: ", fontCorpoN); Phrase p2 = new Phrase( "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido", fontCorpo); pCorpoTres12.add(p1); pCorpoTres12.add(p2); cellCorpopTres.addElement(pCorpoTres1); cellCorpopTres.addElement(pCorpoTres2); cellCorpopTres.addElement(pCorpoTres3); cellCorpopTres.addElement(pCorpoTres4); cellCorpopTres.addElement(pCorpoTres5); cellCorpopTres.addElement(pCorpoTres6); cellCorpopTres.addElement(pCorpoTres7); cellCorpopTres.addElement(pCorpoTres8); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres9); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres10); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres11); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres12); pTableCorpoTres.addCell(cellCorpopTres); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas e Carimbo".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 f= new File("Documentos\\"+user+"\\Seguro Maritimo\\"); // f.mkdirs(); // f =new File(f.getAbsoluteFile()+"\\"+"Certificado Seguro Maritimo "+sdf.format(new Date())+".pdf"); File f = new File(arquivo + "/" + user + "/Seguro Maritimo/"); f.mkdirs(); String Ddata = sdf.format(new Date()); f = new File(f.getAbsoluteFile() + "/" + "Certificado Seguro Maritimo " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Maritimo/" + "Certificado Seguro Maritimo " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); 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(pTableNull); documento.add(pTableCorpoUm); documento.add(pTableNull); documento.add(pTableCorpoDois); documento.add(pTableCorpoTres); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.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:Export.CertificadoViatura.java
public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vf, String user, String moeda, String arquivo) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH'.'mm'.'ss"); SimpleDateFormat sdfPT = new SimpleDateFormat("dd/MM/yyyy"); try {//from w w w. j a v a2 s . c o m Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(2f, 2f, 35f, 5f); // File ff= new File("Documentos\\"+user+"\\Seguro Automovel\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Certificado Seguro Automovel "+sdf.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Automovel/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Certificado Seguro Automovel " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Automovel/" + "Certificado Seguro Automovel " + 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); } // MyFooter event = new MyFooter(); // writer.setPageEvent(event); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.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, 7.5f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC); documento.open(); int total = vf.getInfo().size(); int i = 0; for (Veiculo v : vf.getInfo()) { i++; PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); pTableEmpresaPricipal.setWidthPercentage(93f); 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(190f, 100f); 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 pTableTitulo = new PdfPTable(1); Paragraph PTitulo = new Paragraph(new Phrase("", fontCorpo)); Phrase pTitulo = new Phrase("Certificado Seguro de automvel".toUpperCase(), fontCorpoNG); Phrase pTituloUK = new Phrase("\nCertificate of motor insurance".toUpperCase(), fontUK); PTitulo.add(pTitulo); PTitulo.add(pTituloUK); PdfPCell cellTitulo = new PdfPCell(PTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableDetalhes = new PdfPTable(new float[] { 55, 45 }); pTableDetalhes.setWidthPercentage(93f); Paragraph pNunCetificado = new Paragraph(new Phrase("", fontCorpo)); pNunCetificado.add(new Phrase("1. Certificado: ", fontCorpo)); pNunCetificado.add(new Phrase(v.getCertificado() == null || v.getCertificado().equals("") ? "" : v.getCertificado().toUpperCase(), fontCorpoN)); pNunCetificado.add(new Phrase("\n1. Certificate NO".toUpperCase(), fontUK)); pNunCetificado.setPaddingTop(0f); ClienteI ci = new ClienteI(numCliente); Paragraph pNomeSegurado = new Paragraph(new Phrase("", fontCorpo)); pNomeSegurado.add(new Phrase("3. Segurado: ", fontCorpo)); pNomeSegurado.add(new Phrase(ci.getNOME_().toUpperCase(), fontCorpoN)); pNomeSegurado.add(new Phrase("\n3. Insured".toUpperCase(), fontUK)); pNomeSegurado.setPaddingTop(0f); Paragraph pMarca = new Paragraph(new Phrase("", fontCorpo)); pMarca.add(new Phrase("5. Marca do Veiculo: ", fontCorpo)); pMarca.add(new Phrase((v.getMarca() == null) ? " " : v.getMarca().toUpperCase(), fontCorpoN)); pMarca.add(new Phrase("\n5. vehicle mark".toUpperCase(), fontUK)); // pMarca.setPaddingTop(1f); Paragraph pModelo = new Paragraph(new Phrase("", fontCorpo)); pModelo.add(new Phrase("7. Modelo do Veiculo: ", fontCorpo)); pModelo.add(new Phrase((v.getModelo() == null) ? " " : v.getModelo().toUpperCase(), fontCorpoN)); pModelo.add(new Phrase("\n7. Model Vehicle".toUpperCase(), fontUK)); pModelo.setPaddingTop(0f); Paragraph pPeriodo = new Paragraph(new Phrase("", fontCorpo)); pPeriodo.add(new Phrase("9. Perodo de Seguro - De: ", fontCorpo)); pPeriodo.add(new Phrase( (sdfPT.format(c.getDataInicio()) + " " + sdfPT.format(c.getDataFim())).toUpperCase(), fontCorpoN)); pPeriodo.add(new Phrase("\n9. period of insurance - from to".toUpperCase(), fontUK)); pPeriodo.setPaddingTop(0f); Paragraph pCategoria = new Paragraph(new Phrase("", fontCorpo)); pCategoria.add(new Phrase("11. Categoria/Uso do Veculo: ", fontCorpo)); pCategoria.add(new Phrase(" ", fontCorpoN)); pCategoria.add(new Phrase("\n11. category/use of vehicle".toUpperCase(), fontUK)); pCategoria.setPaddingTop(0f); PdfPCell cellDetalhesRi = new PdfPCell(); cellDetalhesRi.addElement(pNunCetificado); cellDetalhesRi.addElement(pNomeSegurado); cellDetalhesRi.addElement(pMarca); cellDetalhesRi.addElement(pModelo); cellDetalhesRi.addElement(pPeriodo); cellDetalhesRi.addElement(pCategoria); Paragraph pNumApolice = new Paragraph(new Phrase("", fontCorpo)); pNumApolice.add(new Phrase("2. Aplice N ", fontCorpo)); pNumApolice.add(new Phrase(numApolice, fontCorpoN)); pNumApolice.add(new Phrase("\n2. policy no".toUpperCase(), fontUK)); pNumApolice.setPaddingTop(0f); Paragraph pOcupacaoSegurado = new Paragraph(new Phrase("", fontCorpo)); pOcupacaoSegurado.add(new Phrase("4. Ocupao do Seguros: ", fontCorpo)); pOcupacaoSegurado.add(new Phrase(ci.getPROFISSAO_().toUpperCase(), fontCorpoN)); pOcupacaoSegurado.add(new Phrase("\n4. insured's occupation".toUpperCase(), fontUK)); pOcupacaoSegurado.setPaddingTop(0f); Paragraph pNumChassi = new Paragraph(new Phrase("", fontCorpo)); pNumChassi.add(new Phrase("6. N de Chassi/Motor: ", fontCorpo)); pNumChassi.add(new Phrase(v.getChassi() + ((v.getNumMotor() == null || v.getNumMotor().isEmpty()) ? " " : "/" + v.getNumMotor()), fontCorpoN)); pNumChassi.add(new Phrase("\n6 EnGINE", fontUK)); pNumChassi.setPaddingTop(0f); Paragraph pDataFabrico = new Paragraph(new Phrase("", fontCorpo)); pDataFabrico.add(new Phrase("8. Data de Fabrico: ", fontCorpo)); pDataFabrico.add(new Phrase(((v.getAnoFabrico() == null) ? " " : v.getAnoFabrico()), fontCorpo)); pDataFabrico.add(new Phrase("\n8. Date of manofacturing", fontUK)); pDataFabrico.setPaddingTop(0f); Paragraph pTipoCobertura = new Paragraph(new Phrase("", fontCorpo)); pTipoCobertura.add(new Phrase("10. Tipo de Cobertura: ", fontCorpo)); pTipoCobertura .add(new Phrase( ((v.getTipoCobertura() != null) ? (vf.getVeiculo().getTipoCobertura().equals("41") ? "Contra Terceiros".toUpperCase() : (vf.getVeiculo().getTipoCobertura().equals("42") ? "CONTRA Todos os riscos".toUpperCase() : (vf.getVeiculo().getTipoCobertura().equals("43") ? "Compreensivo limitado".toUpperCase() : vf.getVeiculo().getTipoCobertura()))) : " "), fontCorpoN)); pTipoCobertura.add(new Phrase("\n10. Tipo of Cover".toUpperCase(), fontUK)); pTipoCobertura.setPaddingTop(0f); PdfPCell cellDetalhesLe = new PdfPCell(); cellDetalhesLe.addElement(pNumApolice); cellDetalhesLe.addElement(pOcupacaoSegurado); cellDetalhesLe.addElement(pNumChassi); cellDetalhesLe.addElement(pDataFabrico); cellDetalhesLe.addElement(pTipoCobertura); pTableDetalhes.addCell(cellDetalhesRi); pTableDetalhes.addCell(cellDetalhesLe); String f = ""; Paragraph para = new Paragraph(new Phrase("", fontCorpo)); para.add(new Phrase("12. Pessoas ou Classe de Pessoas Habilitadas Para Conduzir", fontCorpoN)); para.add(new Phrase("\n12. Persons or Class of Persons Entitled to Drive", fontUK)); pTableDetalhes.addCell(new PdfPCell(para)); para = new Paragraph(new Phrase("", fontCorpo)); para.add(new Phrase("14. Categorias/Uso de Veculos", fontCorpoN)); para.add(new Phrase("\n14. Categories / Use of Vehicles", fontUK)); pTableDetalhes.addCell(new PdfPCell(para)); Paragraph p11 = new Paragraph(new Phrase("", fontCorpo)); p11.add(new Phrase( "Qualquer pessoa que conduza sob a ordem do detentor da aplice ou com a sua permisso:", fontCorpo)); p11.add(new Phrase("\nAny person who is driving on the policy holder's or with his permission", fontUK)); p11.setPaddingTop(0f); Paragraph p12 = new Paragraph(new Phrase("", fontCorpo)); p12.add(new Phrase( "Desde que o/a condutor/a esteja habilitado/a para conduzir de acordo com a licena/normas que regulam " + "a conduo de veculos a motor ou instrues para conduo lhe tenha sido passada e no esteja impedido de conduzir por" + " ordem do tribunal ou por alguma outra razo.", fontCorpo)); p12.add(new Phrase( "\nProvided that the person diving is permitted in accodance with the licensing or outher laws or regulations to dive the" + "motor vehicles or has been premitted and is not disiqualified by order of a court of law or reason of any enactment or regulation in that behalf from diving such motor vehice", fontUK)); p12.setPaddingTop(0f); Paragraph p13 = new Paragraph(new Phrase("", fontCorpo)); p13.add(new Phrase("13. Limite para uso:", fontCorpoN)); p13.add(new Phrase("\n13. Limitation as to use", fontUK)); p13.setPaddingTop(0f); Paragraph p14 = new Paragraph(new Phrase("", fontCorpo)); p14.add(new Phrase(" - Usado apenas como descrito na categoria aqui indicada.", fontCorpo)); p14.add(new Phrase("\n - Used only as prescribed under the applicable category stated there in.", fontUK)); p14.setPaddingTop(0f); Paragraph p15 = new Paragraph(new Phrase("", fontCorpo)); p15.add(new Phrase( " - Em todo caso, a aplice no cobre corridas, prova de segurana teste de velocidade, nem para qualquer outro propsito relacionado com a venda do automvel.", fontCorpo)); p15.add(new Phrase( "\n - In all cases, the policy does not cover racing, pace-making, reliability trial, speed testing, nor use for any purpose in connection with the trade", fontUK)); p15.setPaddingTop(0f); cellDetalhesRi = new PdfPCell(); cellDetalhesRi.addElement(p11); cellDetalhesRi.addElement(p12); cellDetalhesRi.addElement(p13); cellDetalhesRi.addElement(p14); cellDetalhesRi.addElement(p15); Paragraph p21 = new Paragraph(new Phrase("", fontCorpo)); p21.add(new Phrase("CATEGORIA 1 ", fontCorpoN)); p21.add(new Paragraph( "- Veculos usados para actividade social, domstica e de lazer e do segurado incluindo uso comercial.", fontCorpo)); p21.add(new Phrase( "Vehicles used for social, domestic and pleasure including business use of the insured.", fontUK)); p21.setPaddingTop(0f); Paragraph p22 = new Paragraph(new Phrase("", fontCorpo)); p22.add(new Phrase("CATEGORIA 2 ", fontCorpoN)); p22.add(new Paragraph("- Veculo pertence ao segurado e usado no transporte de mercadorias.", fontCorpo)); p22.add(new Phrase("Vehicle used for transportation of good and belonging to the insured", fontUK)); p22.setPaddingTop(0f); Paragraph p23 = new Paragraph(new Phrase("", fontCorpo)); p23.add(new Phrase("CATEGORIA 3 ", fontCorpoN)); p23.add(new Paragraph( "- Veculos alugados utilizados no transporte Comercial de mercadorias pertencente terceiros.", fontCorpo)); p23.add(new Phrase( "Vehicles used for commercial transportation of good belonging to third parteis fare paying.", fontUK)); p23.setPaddingTop(0f); Paragraph p24 = new Paragraph(new Phrase("", fontCorpo)); p24.add(new Phrase("CATEGORIA 5 ", fontCorpoN)); p24.add(new Paragraph( "- Veculos a motor com duas ou trs rodas para o transporte pblico de passageiro (mediante pagamento de bilhetes).", fontCorpo)); p24.add(new Phrase("Motor vehicles with two or three wheels for carrying fare paying pessengers.", fontUK)); p24.setPaddingTop(0f); Paragraph p25 = new Paragraph(new Phrase("", fontCorpo)); p25.add(new Phrase("CATEGORIA 6-10 ", fontCorpoN)); p25.add(new Paragraph( "- Veculos para fins especiais: Garagem (6), Escola de Conduo (7), Para Aluguer sem motorista (8), Veculo Pesado (9) e Ambulncia, Transporte de distribuio de mercadoria, etc. (10).", fontCorpo)); p25.add(new Phrase( "To special purposes vehicles: Garage (6) Driving School (7) Haring without driver ( 8) , Heavy trucks ( 9) and ambulance, refuse disposal vans etc. ( 10).", fontUK)); p25.setPaddingTop(0f); cellDetalhesLe = new PdfPCell(); cellDetalhesLe.addElement(p21); cellDetalhesLe.addElement(p22); cellDetalhesLe.addElement(p23); cellDetalhesLe.addElement(p24); cellDetalhesLe.addElement(p25); pTableDetalhes.addCell(cellDetalhesRi); pTableDetalhes.addCell(cellDetalhesLe); PdfPTable pTableArtigo = new PdfPTable(1); pTableArtigo.setWidthPercentage(93f); Paragraph pArtigoCetificado = new Paragraph(new Phrase("", fontCorpo)); pArtigoCetificado.add(new Phrase( "O Contrato de seguro cessa, nos termos da legislao em vigor, os efeitos s 24 horas do dia da alienao do veculo.", fontCorpo)); pArtigoCetificado.add(new Phrase( "\nThe insurance contract ceases, according to law in force, from its effects from 24 hours from the date of alienation of the vehicle.", fontUK)); PdfPCell cellArtigoCetificado = new PdfPCell(pArtigoCetificado); cellArtigoCetificado.setBorder(0); Paragraph pLeis = new Paragraph(new Phrase("", fontCorpo)); pLeis.add(new Phrase( "Este certificado foi emitido em conformidade com os Artigos 1 a 36, lei n 30/2000 da Repblica Democrtica de So Tom e Prncipe e que institui a existncia de uma cobertura pelo seguro", fontCorpo)); pLeis.add(new Phrase( "\nThis certificate is issurd in pursuat to the prevision of Articles 1 to 36 , Law No. 30/2000 of the Democratic Republic of Sao Tome and Principe and it constitutes the existence of an insurance cover", fontUK)); PdfPCell cellLeis = new PdfPCell(pLeis); cellLeis.setBorder(0); pTableArtigo.addCell(cellArtigoCetificado); pTableArtigo.addCell(cellLeis); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell( new Phrase("Assinaturas e Carimbo".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("Nicon Seguros 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); PdfPCell assinaturaUK = new PdfPCell( new Phrase("Signature of Insurer and stamp".toUpperCase(), fontUK)); assinaturaUK.setBorder(0); assinaturaUK.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); assinaturaUK.setColspan(2); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); pTableAssinatura.addCell(assinaturaUK); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableDetalhes); documento.add(pTableNull); documento.add(pTableArtigo); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); if (i != total) documento.newPage(); } 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; }