List of usage examples for com.itextpdf.text Paragraph setSpacingBefore
public void setSpacingBefore(float spacing)
From source file:com.automaster.autoview.server.servlet.PdfServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//from ww w.j a va 2s.c o m this.dataAtual = new Date(System.currentTimeMillis()); this.cnpjUn = null; String tempoDecorrido = " 0"; int codVeiculo = Integer.parseInt(request.getParameter("cod")); String placa = request.getParameter("placa"); Timestamp dataInicio = new Timestamp(Long.parseLong(request.getParameter("dataInicio"))); Timestamp dataFim = new Timestamp(Long.parseLong(request.getParameter("dataFim"))); TimeZone timeZonePadrao = TimeZone.getTimeZone(ZoneId.of("-3")); //System.out.println("Time zone : " + timeZonePadrao); ZzzPosPlacaVeiculoDAO zzzPosPlacaVeiculoDAO = new ZzzPosPlacaVeiculoDAO(); VeiculoDAO veiculoDAO = new VeiculoDAO(); TreeMap<String, String> veiculo = veiculoDAO.buscarVeiculoPorCodigo(codVeiculo); placa = veiculo.get("placa"); //System.out.println("PLACA: "+veiculo.get("placa")); ArrayList<TreeMap<String, String>> posicoes = zzzPosPlacaVeiculoDAO .buscarPosicoesPorIntervaloData(placa, dataInicio, dataFim); int codCliente = Integer.parseInt(veiculo.get("clienteCodCliente")); //System.out.println("COD CLIENTE: "+codCliente); ClienteDAO clienteDAO = null; clienteDAO = new ClienteDAO(); TreeMap<String, String> infoClienteUnidade = clienteDAO.buscarPorCodClienteSimplificado(codCliente); // Get the text that will be added to the PDF // step 1 Document document = new Document(); document.addHeader("Adriano", "AutoMaster"); document.addCreator("Adriano Vale"); document.addAuthor("Adriano Vale"); document.addCreationDate(); document.setPageSize(PageSize.A4.rotate()); // step 2 ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); TableHeader event = new TableHeader(); writer.setPageEvent(event); // step 3 document.open(); // step 4 //getServletContext().getRealPath("/") String url = getServletContext().getRealPath("/"); //"D:\\Users\\Adriano\\Documents\\NetBeansProjects\\JRGWT\\web\\imagens\\logo.jpg" Image logo = Image.getInstance(url + "/imagens/logo.jpg"); logo.setAlignment(Element.ALIGN_CENTER); Paragraph titulo = new Paragraph("Relatrio de Posies", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 20, Font.BOLD)); titulo.setAlignment(Element.ALIGN_CENTER); Paragraph tituloPlaca = new Paragraph("Veculo: " + placa, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 16, Font.BOLD)); tituloPlaca.setAlignment(Element.ALIGN_CENTER); SimpleDateFormat dataFormatadaCabecalho = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); dataFormatadaCabecalho.setTimeZone(timeZonePadrao); Date dataHoraInicio0 = new Date(Long.parseLong(request.getParameter("dataInicio"))); Date dataHoraFim0 = new Date(Long.parseLong(request.getParameter("dataFim"))); Paragraph periodo = new Paragraph( "Perodo: De: " + dataFormatadaCabecalho.format(dataHoraInicio0) + " at: " + dataFormatadaCabecalho.format(dataHoraFim0), new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 16, Font.BOLD)); periodo.setSpacingAfter(10.0f); periodo.setAlignment(Element.ALIGN_CENTER); //PdfPTable tabela = new PdfPTable(new float[]{0.11f, 0.095f, 0.06f, 0.065f, 0.085f, 0.06f, 0.04f, 0.065f, 0.055f, 0.06f, 0.24f, 0.065f}); PdfPTable tabela = new PdfPTable(new float[] { 0.07f, 0.045f, 0.045f, 0.27f }); tabela.setWidthPercentage(98.0f); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell tituloData = new PdfPCell(Phrase.getInstance("Data e Hora")); tituloData.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(tituloData); //tabela.addCell("Data e hora"); PdfPCell tituloVel = new PdfPCell(Phrase.getInstance("Velocidade")); tituloVel.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(tituloVel); PdfPCell tituloIgn = new PdfPCell(Phrase.getInstance("Ignio")); tituloIgn.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(tituloIgn); //tabela.addCell("Latitude"); //tabela.addCell("Longitude"); //tabela.addCell("Satlite"); //tabela.addCell("GPS"); //tabela.addCell("Entrada"); //tabela.addCell("Sada"); //tabela.addCell("Evento"); PdfPCell tituloEnd = new PdfPCell(Phrase.getInstance("Endereo")); tituloEnd.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(tituloEnd); //tabela.addCell("Direo"); double latAnt = 0; double lonAnt = 0; double latAtual = 0; double lonAtual = 0; double distanciaTotal = 0; double distancia = 0; event.setHeader("AutoMaster"); for (int i = 0; i < posicoes.size(); i++) { //for (int col = 0; col < posicoes.get(i).size(); col++) { if (i == 0) { distancia = 0; //System.out.println("linha 00 - PDF"); } else { //System.out.println("linha 01 - PDF"); latAnt = Double.parseDouble(posicoes.get(i - 1).get("lat")); lonAnt = Double.parseDouble(posicoes.get(i - 1).get("lon")); latAtual = Double.parseDouble(posicoes.get(i).get("lat")); lonAtual = Double.parseDouble(posicoes.get(i).get("lon")); //System.out.println("linha 02 - PDF"); if (latAnt == latAtual && lonAnt == lonAtual) { distancia = 0; } else { distancia = caculaDistanciaEntreDoisPontos(latAnt, lonAnt, latAtual, lonAtual); //System.out.println("linha 03 - PDF"); } } distanciaTotal = distanciaTotal + distancia; //System.out.println("linha 04 - PDF"); //TimeZone.setDefault(timeZoneMundial); Date dataHora0 = new Date(Long.parseLong(posicoes.get(i).get("dataHora"))); //System.out.println("dataHora0 : "+dataHora0.toString()); //TimeZone.setDefault(timeZoneCliente); //Date dataHora = new Date(dataHora0.getTime()); SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); dataFormatada.setTimeZone(timeZonePadrao); //System.out.println("dataFormatada : "+dataFormatada); PdfPCell celData = new PdfPCell(Phrase.getInstance(dataFormatada.format(dataHora0))); celData.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(celData); //tabela.addCell(dataFormatada); PdfPCell celVel = new PdfPCell(Phrase.getInstance(posicoes.get(i).get("vel"))); celVel.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(celVel); PdfPCell celIgn = new PdfPCell(Phrase .getInstance(posicoes.get(i).get("ign").equalsIgnoreCase("True") ? "Ligada" : "Desligada")); celIgn.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(celIgn); //tabela.addCell(posicoes.get(i).get("lat")); //tabela.addCell(posicoes.get(i).get("lon")); //tabela.addCell(posicoes.get(i).get("sat")); //tabela.addCell(posicoes.get(i).get("gps")); //tabela.addCell(posicoes.get(i).get("entrada")); //tabela.addCell(posicoes.get(i).get("saida")); //tabela.addCell(posicoes.get(i).get("evento")); PdfPCell celEnd = new PdfPCell( Phrase.getInstance(posicoes.get(i).get("endereco") == null ? "Sem endereo" : posicoes.get(i).get("endereco"))); celEnd.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(celEnd); //tabela.addCell(posicoes.get(i).get("direcao")); //} } //System.out.println("linha 05 - PDF"); tempoDecorrido = calculaDatas(Long.parseLong(posicoes.get(0).get("dataHora")), Long.parseLong(posicoes.get(posicoes.size() - 1).get("dataHora"))); //System.out.println("linha 06 - PDF"); int index = 0; String kms = "0"; String m = ""; double metros = 0; //System.out.println("linha 07 - PDF"); if (distanciaTotal > 0) { //System.out.println("linha 08 - PDF"); BigDecimal decimalFormatado = new BigDecimal(distanciaTotal).setScale(2, RoundingMode.HALF_EVEN); //System.out.println("linha 09 - PDF"); index = String.valueOf(decimalFormatado).indexOf("."); kms = String.valueOf(decimalFormatado).substring(0, index); m = "0" + (String.valueOf(decimalFormatado).substring(index)); metros = Double.parseDouble(m) * 1000; //System.out.println("linha 10 - PDF"); } /*document.add(new Paragraph(String.format( "You have submitted the following text using the %s method:", request.getMethod()))); document.add(new Paragraph(text));*/ //System.out.println("linha 11 - PDF"); Paragraph kilometragem = new Paragraph( "Percorridos: " + kms + " KM e " + String.valueOf(metros) + " metros. Tempo: " + tempoDecorrido, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 16, Font.BOLD)); //System.out.println("linha 12 - PDF"); periodo.setSpacingAfter(10.0f); periodo.setAlignment(Element.ALIGN_CENTER); // step 5 document.add(logo); document.add(titulo); document.add(tituloPlaca); document.add(periodo); document.add(tabela); document.add(kilometragem); String dia = new SimpleDateFormat("dd").format(dataAtual); String ano = new SimpleDateFormat("yyyy").format(dataAtual); int mes = dataAtual.getMonth(); String mesEscrito = null; switch (mes) { case 0: mesEscrito = "janeiro"; break; case 1: mesEscrito = "fevereiro"; break; case 2: mesEscrito = "maro"; break; case 3: mesEscrito = "abril"; break; case 4: mesEscrito = "maio"; break; case 5: mesEscrito = "junho"; break; case 6: mesEscrito = "julho"; break; case 7: mesEscrito = "agosto"; break; case 8: mesEscrito = "setembro"; break; case 9: mesEscrito = "outubro"; break; case 10: mesEscrito = "novembro"; break; case 11: mesEscrito = "dezembro"; break; } String textRodape = infoClienteUnidade.get("cidadeUnidade") + " , " + infoClienteUnidade.get("estadoUnidade") + " " + dia + " de " + mesEscrito + " de " + ano + "."; Paragraph localData = new Paragraph(textRodape, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 12, Font.PLAIN)); localData.setAlignment(Element.ALIGN_RIGHT); localData.setSpacingBefore(30.0f); localData.setSpacingAfter(10.0f); document.add(localData); Image assinatura = Image.getInstance(url + "/imagens/assinatura.png"); assinatura.setAlignment(Element.ALIGN_CENTER); assinatura.scaleAbsolute(185, 91); document.add(assinatura); Paragraph infoEmpresa1 = new Paragraph("AUTO MASTER LTDA", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 12, Font.BOLD)); infoEmpresa1.setAlignment(Element.ALIGN_CENTER); infoEmpresa1.setSpacingAfter(1f); document.add(infoEmpresa1); Paragraph infoEmpresa2 = new Paragraph("___________________________", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 12, Font.BOLD)); infoEmpresa2.setAlignment(Element.ALIGN_CENTER); document.add(infoEmpresa2); String cnpjEmpresa = formataCNPJ(infoClienteUnidade.get("cnpjUnidade")); Paragraph infoEmpresa3 = new Paragraph(cnpjEmpresa, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 12, Font.BOLD)); infoEmpresa3.setAlignment(Element.ALIGN_CENTER); document.add(infoEmpresa3); document.close(); // setting some response headers response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); // setting the content type response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment; filename=Historico-" + placa + ".pdf"); // the contentlength response.setContentLength(baos.size()); // write ByteArrayOutputStream to the ServletOutputStream OutputStream os = response.getOutputStream(); baos.writeTo(os); os.flush(); os.close(); } catch (DocumentException e) { throw new IOException(e.getMessage()); } // response.setContentType("text/html;charset=UTF-8"); // try (PrintWriter out = response.getWriter()) { // /* TODO output your page here. You may use following sample code. */ // out.println("<!DOCTYPE html>"); // out.println("<html>"); // out.println("<head>"); // out.println("<title>Servlet PdfServlet</title>"); // out.println("</head>"); // out.println("<body>"); // out.println("<h1>Servlet PdfServlet at " + request.getContextPath() + "</h1>"); // out.println("</body>"); // out.println("</html>"); // } }
From source file:com.bdaum.zoom.email.internal.job.PdfJob.java
License:Open Source License
private void printPage(Document document, int pageNo, MultiStatus status, IProgressMonitor monitor) throws DocumentException, IOException { if (pageNo > 1) document.newPage();/* w w w . j a va 2 s . c o m*/ document.setPageCount(pageNo); final Display display = Display.getDefault(); int pageItem = 0; if (!layout.getTitle().isEmpty()) { String title = PageProcessor.computeTitle(layout.getTitle(), fileName, now, assets.size(), pageNo, pages, collection, meta); Paragraph p = new Paragraph(title, FontFactory.getFont(FontFactory.HELVETICA, titleSize, Font.BOLD, BaseColor.DARK_GRAY)); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(layout.getSubtitle().isEmpty() ? titleLead + upperWaste : titleLead); document.add(p); } if (!layout.getSubtitle().isEmpty()) { String subtitle = PageProcessor.computeTitle(layout.getSubtitle(), fileName, now, assets.size(), pageNo, pages, collection, meta); Paragraph p = new Paragraph(subtitle, FontFactory.getFont(FontFactory.HELVETICA, subtitleSize, Font.NORMAL, BaseColor.DARK_GRAY)); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(subtitleLead + upperWaste); document.add(p); } IVolumeManager vm = Core.getCore().getVolumeManager(); PdfPTable table = new PdfPTable(layout.getColumns()); try (Assetbox box = new Assetbox(null, status, false)) { for (int i = 0; i < rows; i++) { int ni = i * layout.getColumns(); for (int j = 0; j < layout.getColumns(); j++) { int a = (pageNo - 1) * imagesPerPage + ni + j; PdfPCell cell; if (a >= assets.size() || monitor.isCanceled()) cell = new PdfPCell(); else { final int dpi = quality == Constants.SCREEN_QUALITY ? SCREENDPI : PRINTERDPI; final int pixelWidth = (int) (imageWidth * dpi / 72); final int pixelHeight = (int) (imageHeight * dpi / 72); Asset asset = assets.get(a); zimage = new ZImage(ImageUtilities.loadThumbnail(display, asset.getJpegThumbnail(), cms, SWT.IMAGE_JPEG, true), null); org.eclipse.swt.graphics.Rectangle bounds = zimage.getBounds(); URI uri = vm.findExistingFile(asset, false); if (uri != null) { boolean r = asset.getRotation() % 180 != 0; double w = r ? asset.getHeight() : asset.getWidth(); double h = r ? asset.getWidth() : asset.getHeight(); double scale = w == 0 || h == 0 ? 1d : Math.min(pixelWidth / w, pixelHeight / h); scale = (scale <= 0.5d) ? 0.5d : 1d; File file = box.obtainFile(uri); if (file != null) try { ZImage hzimage = CoreActivator.getDefault().getHighresImageLoader().loadImage( null, status, file, asset.getRotation(), asset.getFocalLengthIn35MmFilm(), null, scale, Double.MAX_VALUE, true, ImageConstants.SRGB, null, unsharpMask, null, fileWatcher, opId, null); if (hzimage != null) { zimage.dispose(); zimage = hzimage; } } catch (UnsupportedOperationException e) { // do nothing } } display.syncExec(() -> { int kl = (keyLine > 0) ? (int) Math.max(1, (keyLine * dpi / 144)) : 0; org.eclipse.swt.graphics.Rectangle ibounds = zimage.getBounds(); double factor = Math.min((double) pixelWidth / ibounds.width, (double) pixelHeight / ibounds.height); int lw = pixelWidth + 2 * kl; int lh = pixelHeight + 2 * kl; Image newImage = new Image(display, lw, lh); GC gc = new GC(newImage); try { gc.setAntialias(SWT.ON); gc.setInterpolation(SWT.HIGH); gc.setAdvanced(true); gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); gc.fillRectangle(0, 0, lw, lh); int width = (int) (ibounds.width * factor + 2 * kl); int height = (int) (ibounds.height * factor + 2 * kl); int xoff = (lw - width) / 2; int yoff = (lh - height) / 2; if (kl > 0) { gc.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY)); gc.fillRectangle(xoff, yoff, width, height); } zimage.draw(gc, 0, 0, ibounds.width, ibounds.height, xoff + kl, yoff + kl, width - 2 * kl, height - 2 * kl, ZImage.CROPPED, pixelWidth, pixelHeight, false); } finally { gc.dispose(); zimage.dispose(); zimage = new ZImage(newImage, null); } }); bounds = zimage.getBounds(); File jpegFile = ImageActivator.getDefault().createTempFile("PdfImg", ".jpg"); //$NON-NLS-1$//$NON-NLS-2$ tempFiles.add(jpegFile); try (FileOutputStream out = new FileOutputStream(jpegFile)) { zimage.saveToStream(monitor, true, ZImage.UNCROPPED, SWT.DEFAULT, SWT.DEFAULT, out, SWT.IMAGE_JPEG, jpegQuality); } zimage.dispose(); com.itextpdf.text.Image pdfImage = com.itextpdf.text.Image.getInstance(jpegFile.getPath()); double factor = Math.min(imageWidth / bounds.width, imageHeight / bounds.height); pdfImage.setInterpolation(true); pdfImage.scaleToFit((float) (bounds.width * factor), (float) (bounds.height * factor)); cell = new PdfPCell(pdfImage, false); cell.setHorizontalAlignment(Element.ALIGN_CENTER); monitor.worked(1); } cell.setFixedHeight((float) imageHeight); cell.setBorderWidth(0); table.addCell(cell); } renderCaptions(pageNo, seqNo, pageItem, table, ni, layout.getCaption1()); renderCaptions(pageNo, seqNo, pageItem, table, ni, layout.getCaption2()); pageItem += layout.getColumns(); seqNo += layout.getColumns(); if (verticalGap > 0 && i < rows - 1) for (int j = 0; j < layout.getColumns(); j++) { PdfPCell cell = new PdfPCell(); cell.setFixedHeight(verticalGap); cell.setBorderWidth(0); table.addCell(cell); } } table.setWidthPercentage(100f); document.add(table); if (!layout.getFooter().isEmpty()) { String footer = PageProcessor.computeTitle(layout.getFooter(), fileName, now, assets.size(), pageNo, pages, collection, meta); Paragraph p = new Paragraph(footer, FontFactory.getFont(FontFactory.HELVETICA, subtitleSize, Font.NORMAL, BaseColor.DARK_GRAY)); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(upperWaste / 2 + footerLead); document.add(p); } } }
From source file:com.bdaum.zoom.email.internal.job.PdfJob.java
License:Open Source License
private void renderCaptions(int pageNo, int seqNo, int pageItem, PdfPTable table, int ni, String caption) { if (!caption.isEmpty()) { for (int j = 0; j < layout.getColumns(); j++) { int a = (pageNo - 1) * imagesPerPage + ni + j; PdfPCell cell;// w w w. jav a 2 s . c o m if (a >= assets.size()) cell = new PdfPCell(); else { String cc = PageProcessor.computeCaption(caption, Constants.PI_ALL, assets.get(a), collection, seqNo + j + 1, pageItem + j + 1); Paragraph p = new Paragraph(cc, FontFactory.getFont(FontFactory.HELVETICA, fontSize, Font.NORMAL, BaseColor.DARK_GRAY)); p.setSpacingBefore(0); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); } cell.setBorderWidth(0); table.addCell(cell); } } }
From source file:com.bougsid.printers.PrintMission.java
public void printMission(Mission mission) { Document document = new Document(PageSize.A4); try {// w w w.j av a2 s. c om File downloadDir = new File(msg.getMessage("application.mission.downloaddir")); if (!downloadDir.exists()) { downloadDir.mkdir(); } System.out.println("Dir =" + downloadDir.getPath()); PdfWriter.getInstance(document, new FileOutputStream(downloadDir.getPath() + "/" + mission.getUuid() + ".pdf")); document.open(); Paragraph p = new Paragraph(); p.setSpacingAfter(60); document.add(p); //header Paragraph paragraph = new Paragraph( msg.getMessage("mission.pdf.school") + " " + mission.getIdMission() + " ", DEFAULT_FONT); Phrase phrase = new Phrase(msg.getMessage("mission.pdf.city") + " " + LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); paragraph.add(phrase); paragraph.setSpacingAfter(50); document.add(paragraph); //title PdfPTable table = new PdfPTable(1); table.setWidthPercentage(40); PdfPCell cell = new PdfPCell(new Phrase(msg.getMessage("mission.pdf.title"), FontFactory.getFont(FontFactory.HELVETICA, 18))); cell.setBorderWidth(1); cell.setPadding(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setSpacingAfter(40); document.add(table); //content table = new PdfPTable(2); table.setWidthPercentage(100); //line 1 cell = new PdfPCell(new Paragraph(mission.getEmploye().getCivilite().getLabel(), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getFullName(), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 2 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.matricule"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getMatricule(), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 3 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.grade"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getFonction(), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); if (mission.getEntreprise() != null) { //line 4 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.text_1"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.text_1_2"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 5 cell = new PdfPCell(new Paragraph(" ", DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph(" - " + mission.getEntreprise().getNom(), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); } //line 6 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.lieu"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); p = new Paragraph(); p.setFont(DEFAULT_FONT); for (Ville ville : mission.getVilles()) { p.add(ville.getNom() + "\n"); } cell = new PdfPCell(p); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 7 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.startdate"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph( ": " + mission.getStartDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + " Heure : " + mission.getStartDate().format(DateTimeFormatter.ofPattern("HH:mm")), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 8 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.enddate"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); cell = new PdfPCell(new Paragraph( ": " + mission.getEndDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + " Heure : " + mission.getEndDate().format(DateTimeFormatter.ofPattern("HH:mm")), DEFAULT_FONT)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); //line 9 cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.transport"), DEFAULT_FONT_BOLD)); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); switch (mission.getTransportType()) { case PERSONNEL: cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.perso") + " " + mission.getEmploye().getVehicule().getMarque() + " " + msg.getMessage("mission.pdf.mat") + " " + mission.getEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT)); break; case Accompagnement: cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.accomp") + " " + mission.getAccompEmploye().getCivilite() + " " + mission.getAccompEmploye().getFullName() + " " + msg.getMessage("mission.pdf.accomp.voitue") + " " + mission.getAccompEmploye().getVehicule().getMarque() + " " + msg.getMessage("mission.pdf.mat") + " " + mission.getAccompEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT)); break; case Service: cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.service") + " " + mission.getEmploye().getVehicule().getMarque() + " " + msg.getMessage("mission.pdf.mat") + " " + mission.getEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT)); break; default: { cell = new PdfPCell(new Paragraph( ": " + mission.getTransportType().getLabel() + " " + msg.getMessage("mission.pdf.taxi"), DEFAULT_FONT)); } } cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(20); table.addCell(cell); table.setSpacingAfter(40); document.add(table); //note document.add(new Paragraph(msg.getMessage("mission.pdf.TEXT_2"), DEFAULT_FONT)); //signature if (mission.getEmploye().getGrade().getType() == GradeType.DG) { } else { Employe dir = employeService.getDG(); if (dir != null) paragraph = new Paragraph(dir.getFullName(), DEFAULT_FONT); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setSpacingBefore(40); document.add(paragraph); paragraph = new Paragraph(msg.getMessage("mission.pdf.DG"), DEFAULT_FONT); paragraph.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph); } } catch (DocumentException ex) { ex.printStackTrace(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } document.close(); // try { // Desktop.getDesktop().open(new File("./order.pdf")); // } catch (IOException ex) { // JOptionPane.showMessageDialog(null, "Fichier gner mais ne peut pas etre ouvert vrifier le dossier"); // } }
From source file:com.centurylink.mdw.pdf.PdfExportHelper.java
License:Apache License
private void printGraphDocumentation(Process process, Chapter chapter) throws Exception { Section section;/* w w w . j a v a 2s. co m*/ String tmp; if (process.isEmbeddedProcess()) { String id = process.getAttribute(WorkAttributeConstant.LOGICAL_ID); if (id == null || id.length() == 0) id = process.getId().toString(); tmp = "Subprocess " + id + ": \"" + process.getName().replace('\n', ' ') + "\""; } else { tmp = "Process Description"; } Paragraph sTitle = new Paragraph(tmp, sectionFont); sTitle.setSpacingBefore(10); section = chapter.addSection(sTitle, 2); String summary = process.getDescription(); if (summary != null && summary.length() > 0) printBoldParagraphs(section, summary); String detail = process.getAttribute(WorkAttributeConstant.DOCUMENTATION); if (detail != null && detail.length() > 0) { printHtmlParagraphs(section, getHtmlContent(detail), 0); } if (!process.getAttributes().isEmpty() && process.isEmbeddedProcess()) { printAttributes(section, process.getAttributes(), 2); } }
From source file:com.coderbd.pos.pdf.BarcodePdf.java
public void generateBarcodePdf(int amount) throws UnsupportedEncodingException { try {// w w w . ja v a2 s .c o m String filename = directory + "\\" + barcodeData + ".pdf"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); PdfContentByte cb = writer.getDirectContent(); Barcode128 code25 = new Barcode128(); code25.setGenerateChecksum(true); code25.setCode(barcodeData); code25.setSize(10f); code25.setX(1.50f); PdfPTable pdfPTable = new PdfPTable(3); float[] widths = { 0.45f, .10f, .45f }; pdfPTable.setWidths(widths); String codeName = getCodeName(shop.getShopName(), shop.getShopId(), amount); System.out.println("BarCodeName:" + codeName); Image image = code25.createImageWithBarcode(cb, null, null); Paragraph paragraph = new Paragraph(codeName); paragraph.setSpacingBefore(10.0f); PdfPCell title = new PdfPCell(paragraph); title.setBorder(Rectangle.NO_BORDER); PdfPCell barcodeCell = new PdfPCell(image, true); barcodeCell.setBorder(Rectangle.NO_BORDER); PdfPCell blank = new PdfPCell(); blank.setBorder(Rectangle.NO_BORDER); Paragraph blankParagraph = new Paragraph("- -"); PdfPCell pdfPCellBlank = new PdfPCell(blankParagraph); pdfPCellBlank.setBorder(Rectangle.NO_BORDER); for (int i = 0; i < barcodeQuantity; i++) { /** * This is for barcode pdf title */ pdfPTable.addCell(title); pdfPTable.addCell(blank); pdfPTable.addCell(title); /** * This is for barcode image */ pdfPTable.addCell(barcodeCell); pdfPTable.addCell(blank); pdfPTable.addCell(barcodeCell); /** * Blank space after barcode image */ pdfPTable.addCell(pdfPCellBlank); pdfPTable.addCell(blank); pdfPTable.addCell(pdfPCellBlank); } document.add(pdfPTable); document.close(); } catch (DocumentException | FileNotFoundException dex) { System.out.println(dex.getMessage()); } }
From source file:com.coderbd.pos.pdf.BarcodePdf.java
public void generateBarcodePdf(boolean fixedRate, Product p) throws UnsupportedEncodingException { try {//from w w w.j a v a2 s .c o m String filename = directory + "\\" + barcodeData + ".pdf"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); PdfContentByte cb = writer.getDirectContent(); Barcode128 code25 = new Barcode128(); code25.setGenerateChecksum(true); code25.setCode(barcodeData); code25.setSize(10f); code25.setX(1.50f); PdfPTable pdfPTable = new PdfPTable(3); float[] widths = { 0.45f, .10f, .45f }; pdfPTable.setWidths(widths); String codeName = getCodeName(shop.getShopName(), shop.getShopId(), (int) p.getProductBuyRate()); System.out.println("BarCodeName:" + codeName); Image image = code25.createImageWithBarcode(cb, null, null); Paragraph paragraph = new Paragraph(codeName); paragraph.setSpacingBefore(10.0f); PdfPCell title = new PdfPCell(paragraph); title.setBorder(Rectangle.NO_BORDER); PdfPCell barcodeCell = new PdfPCell(image, true); barcodeCell.setBorder(Rectangle.NO_BORDER); PdfPCell blank = new PdfPCell(); blank.setBorder(Rectangle.NO_BORDER); Paragraph blankParagraph = new Paragraph("- -"); PdfPCell pdfPCellBlank = new PdfPCell(blankParagraph); pdfPCellBlank.setBorder(Rectangle.NO_BORDER); for (int i = 0; i < barcodeQuantity; i++) { /** * This is for barcode pdf title */ pdfPTable.addCell(title); pdfPTable.addCell(blank); pdfPTable.addCell(title); /** * This is for barcode image */ pdfPTable.addCell(barcodeCell); pdfPTable.addCell(blank); pdfPTable.addCell(barcodeCell); /** * Blank space after barcode image */ pdfPTable.addCell(pdfPCellBlank); pdfPTable.addCell(blank); pdfPTable.addCell(pdfPCellBlank); } document.add(pdfPTable); document.close(); } catch (DocumentException | FileNotFoundException dex) { System.out.println(dex.getMessage()); } }
From source file:com.coderbd.pos.pdf.CodePDF.java
public boolean genCodeVer2Pdf() throws UnsupportedEncodingException { if (isFixedRated == true) { barcodeQuantity = 12;/*w ww . j a v a 2s .c om*/ } else { barcodeQuantity = 15; } try { String filename = ""; if (isFixedRated) { filename = directory + "\\" + product.getProductBarcode() + "_FIXED_TK" + ".pdf"; } else { filename = directory + "\\" + product.getProductBarcode() + ".pdf"; } Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); PdfContentByte cb = writer.getDirectContent(); Barcode128 code25 = new Barcode128(); code25.setGenerateChecksum(true); code25.setCode(product.getProductBarcode()); code25.setSize(10f); code25.setX(1.50f); PdfPTable pdfPTable = new PdfPTable(7); pdfPTable.setWidthPercentage(98); float[] widths = { 0.22f, 0.04f, 0.22f, 0.04f, 0.22f, 0.04f, 0.22f }; pdfPTable.setWidths(widths); String codeName = getCodeName(product.getShop().getShopName(), product.getShop().getShopId(), (int) product.getProductBuyRate()); System.out.println("BarCodeName:" + codeName); Image image = code25.createImageWithBarcode(cb, null, null); Font titleArialFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.NORMAL); Font priceFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.BOLD); Paragraph paragraph = new Paragraph(codeName, titleArialFont); paragraph.setSpacingBefore(10.0f); PdfPCell title = new PdfPCell(paragraph); title.setBorder(Rectangle.NO_BORDER); Paragraph fixedTKParagraph = new Paragraph("FIXED TK: " + product.getProductSellRate(), priceFont); PdfPCell fixedRateCell = new PdfPCell(fixedTKParagraph); fixedRateCell.setBorder(Rectangle.NO_BORDER); PdfPCell barcodeCell = new PdfPCell(image, true); barcodeCell.setBorder(Rectangle.NO_BORDER); PdfPCell blank = new PdfPCell(); blank.setBorder(Rectangle.NO_BORDER); Paragraph blankParagraph = new Paragraph("- -"); PdfPCell pdfPCellBlank = new PdfPCell(blankParagraph); pdfPCellBlank.setBorder(Rectangle.NO_BORDER); for (int i = 0; i < barcodeQuantity; i++) { /** * This is for barcode pdf title */ pdfPTable.addCell(title); pdfPTable.addCell(blank); pdfPTable.addCell(title); pdfPTable.addCell(blank); pdfPTable.addCell(title); pdfPTable.addCell(blank); pdfPTable.addCell(title); /** * This is for barcode image */ pdfPTable.addCell(barcodeCell); pdfPTable.addCell(blank); pdfPTable.addCell(barcodeCell); pdfPTable.addCell(blank); pdfPTable.addCell(barcodeCell); pdfPTable.addCell(blank); pdfPTable.addCell(barcodeCell); /** * */ if (isFixedRated == true) { pdfPTable.addCell(fixedRateCell); pdfPTable.addCell(blank); pdfPTable.addCell(fixedRateCell); pdfPTable.addCell(blank); pdfPTable.addCell(fixedRateCell); pdfPTable.addCell(blank); pdfPTable.addCell(fixedRateCell); } /** * Blank space after barcode image */ pdfPTable.addCell(pdfPCellBlank); pdfPTable.addCell(blank); pdfPTable.addCell(pdfPCellBlank); pdfPTable.addCell(blank); pdfPTable.addCell(pdfPCellBlank); pdfPTable.addCell(blank); pdfPTable.addCell(pdfPCellBlank); } document.add(pdfPTable); document.add(new Paragraph( "Shop Name: " + product.getShop().getShopName() + ", Name:" + product.getProductName() + "\n,Qty: " + product.getProductStock() + ", " + new Date().toString(), titleArialFont)); document.close(); return true; } catch (DocumentException | FileNotFoundException dex) { System.out.println(dex.getMessage()); return false; } }
From source file:com.debashubham.dumpy.ChainageCalcActivity.java
private void createTable(Section subCatPart) throws DocumentException { PdfPTable entry_table = new PdfPTable(10); entry_table.setWidthPercentage(100); // entry_table.setWidths(new float[]{0.25f,0.5f,0.5f,0.5f,0.5f,0.5f,0.5f,0.5f,0.5f,1.0f}); PdfPCell id = new PdfPCell(new Phrase("Station Point")); id.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell left_row = new PdfPCell(new Phrase("CH. Left(m)")); left_row.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell center_row = new PdfPCell(new Phrase("CH. Center(m)")); center_row.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell right_row = new PdfPCell(new Phrase("CH. Right(m)")); right_row.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell bs = new PdfPCell(new Phrase("BS(m)")); bs.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell is = new PdfPCell(new Phrase("IS(m)")); is.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell fs = new PdfPCell(new Phrase("FS(m)")); fs.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell hi = new PdfPCell(new Phrase("HI(m)")); hi.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rl = new PdfPCell(new Phrase("RL(m)")); rl.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell remarks = new PdfPCell(new Phrase("REMARKS")); remarks.setHorizontalAlignment(Element.ALIGN_CENTER); entry_table.addCell(id);//from w ww. ja v a 2s.c o m entry_table.addCell(left_row); entry_table.addCell(center_row); entry_table.addCell(right_row); entry_table.addCell(bs); entry_table.addCell(is); entry_table.addCell(fs); entry_table.addCell(hi); entry_table.addCell(rl); entry_table.addCell(remarks); entry_table.setHeaderRows(1); int largest = rl_list.size(); Log.e("Total RL:", String.valueOf(largest)); double total_bs = 0, total_fs = 0, first_rl = 0, last_rl = 0; for (int i = 1; i <= largest; i++) { entry_table.addCell(String.valueOf(i)); if (i == 1) first_rl = rl_list.get(i); if (i == largest) last_rl = rl_list.get(i); if (left.containsKey(i)) { entry_table.addCell(String.valueOf(left.get(i))); entry_table.addCell(""); entry_table.addCell(""); } else if (center.containsKey(i)) { entry_table.addCell(""); entry_table.addCell(String.valueOf(center.get(i))); entry_table.addCell(""); } else if (right.containsKey(i)) { entry_table.addCell(""); entry_table.addCell(""); entry_table.addCell(String.valueOf(right.get(i))); } else { entry_table.addCell(""); entry_table.addCell(""); entry_table.addCell(""); } if (bs_list.containsKey(i)) { entry_table.addCell(String.valueOf(bs_list.get(i))); total_bs += bs_list.get(i); Log.e("TABLE:", "BS"); } else { entry_table.addCell(""); Log.e("TABLE:", "BS not entered"); } if (is_list.containsKey(i)) { entry_table.addCell(String.valueOf(is_list.get(i))); Log.e("TABLE:", "IS"); } else { entry_table.addCell(""); Log.e("TABLE:", "IS not entered"); } if (fs_list.containsKey(i)) { entry_table.addCell(String.valueOf(fs_list.get(i))); total_fs += fs_list.get(i); Log.e("TABLE:", "FS"); } else { entry_table.addCell(""); Log.e("TABLE:", "FS not entered"); } if (hi_list.containsKey(i)) { entry_table.addCell(String.valueOf(hi_list.get(i))); Log.e("TABLE:", "HI"); } else { entry_table.addCell(""); Log.e("TABLE:", "HI not entered"); } if (rl_list.containsKey(i)) { entry_table.addCell(String.valueOf(rl_list.get(i))); Log.e("TABLE:", "RL"); } else { entry_table.addCell(""); Log.e("TABLE:", "RL not entered"); } if (remarks_list.containsKey(i)) { entry_table.addCell(String.valueOf(remarks_list.get(i))); Log.e("TABLE:", "REMARKS"); } else { entry_table.addCell(""); Log.e("TABLE:", "REMARKS not entered"); } } subCatPart.add(entry_table); Log.e("Total BS:", String.valueOf(total_bs)); Log.e("Total FS:", String.valueOf(total_fs)); Log.e("First RL:", String.valueOf(first_rl)); Log.e("Last RL:", String.valueOf(last_rl)); Paragraph check_para = new Paragraph("Arithmetic Check:", subFont); addEmptyLine(check_para, 2); check_para.add("Summation(BS) - Summation(FS) = Last RL - First RL"); addEmptyLine(check_para, 1); double bsfs_diff = Math.round((total_bs - total_fs) * 1000.0) / 1000.0; double rl_diff = Math.round((last_rl - first_rl) * 1000.0) / 1000.0; boolean checktrue = (bsfs_diff) == (rl_diff) ? true : false; check_para.add(String.valueOf(bsfs_diff) + " = " + String.valueOf(rl_diff)); addEmptyLine(check_para, 1); if (checktrue) { check_para.setSpacingBefore(20); check_para.add("OK"); } else { check_para.setSpacingBefore(20); check_para.add("Check Fail!"); } addEmptyLine(check_para, 1); check_para.add("_______________________________________________________"); subCatPart.add(check_para); Paragraph legend_para = new Paragraph("LEGEND:", subFont); addEmptyLine(legend_para, 1); legend_para.add("BS : Back Sight"); addEmptyLine(legend_para, 1); legend_para.add("IS : Intermediate Sight"); addEmptyLine(legend_para, 1); legend_para.add("FS : Fore Sight"); addEmptyLine(legend_para, 1); legend_para.add("HI : Height of Instrument"); addEmptyLine(legend_para, 1); legend_para.add("RL : Reduced Level"); addEmptyLine(legend_para, 1); legend_para.add("CH. : Chainage"); subCatPart.add(legend_para); }
From source file:com.debashubham.dumpy.SimpleCalcActivity.java
private void createTable(Section subCatPart) throws BadElementException { PdfPTable entry_table = new PdfPTable(7); entry_table.setWidthPercentage(100); PdfPCell id = new PdfPCell(new Phrase("Station Point")); id.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell bs = new PdfPCell(new Phrase("BS")); bs.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell is = new PdfPCell(new Phrase("IS")); is.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell fs = new PdfPCell(new Phrase("FS")); fs.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell hi = new PdfPCell(new Phrase("HI")); hi.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rl = new PdfPCell(new Phrase("RL")); rl.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell remarks = new PdfPCell(new Phrase("REMARKS")); remarks.setHorizontalAlignment(Element.ALIGN_CENTER); entry_table.addCell(id);//from w w w.ja v a 2 s . co m entry_table.addCell(bs); entry_table.addCell(is); entry_table.addCell(fs); entry_table.addCell(hi); entry_table.addCell(rl); entry_table.addCell(remarks); entry_table.setHeaderRows(1); int largest = rl_list.size(); Log.e("Total RL:", String.valueOf(largest)); double total_bs = 0, total_fs = 0, first_rl = 0, last_rl = 0; for (int i = 1; i <= largest; i++) { entry_table.addCell(String.valueOf(i)); if (i == 1) first_rl = rl_list.get(i); if (i == largest) last_rl = rl_list.get(i); if (bs_list.containsKey(i)) { entry_table.addCell(String.valueOf(bs_list.get(i))); total_bs += bs_list.get(i); Log.e("TABLE:", "BS"); } else { entry_table.addCell(""); Log.e("TABLE:", "BS not entered"); } if (is_list.containsKey(i)) { entry_table.addCell(String.valueOf(is_list.get(i))); Log.e("TABLE:", "IS"); } else { entry_table.addCell(""); Log.e("TABLE:", "IS not entered"); } if (fs_list.containsKey(i)) { entry_table.addCell(String.valueOf(fs_list.get(i))); total_fs += fs_list.get(i); Log.e("TABLE:", "FS"); } else { entry_table.addCell(""); Log.e("TABLE:", "FS not entered"); } if (hi_list.containsKey(i)) { entry_table.addCell(String.valueOf(hi_list.get(i))); Log.e("TABLE:", "HI"); } else { entry_table.addCell(""); Log.e("TABLE:", "HI not entered"); } if (rl_list.containsKey(i)) { entry_table.addCell(String.valueOf(rl_list.get(i))); Log.e("TABLE:", "RL"); } else { entry_table.addCell(""); Log.e("TABLE:", "RL not entered"); } if (remarks_list.containsKey(i)) { entry_table.addCell(String.valueOf(remarks_list.get(i))); Log.e("TABLE:", "REMARKS"); } else { entry_table.addCell(""); Log.e("TABLE:", "REMARKS not entered"); } } subCatPart.add(entry_table); Log.e("Total BS:", String.valueOf(total_bs)); Log.e("Total FS:", String.valueOf(total_fs)); Log.e("First RL:", String.valueOf(first_rl)); Log.e("Last RL:", String.valueOf(last_rl)); Paragraph check_para = new Paragraph("Arithmetic Check:", subFont); addEmptyLine(check_para, 2); check_para.add("Summation(BS) - Summation(FS) = Last RL - First RL"); addEmptyLine(check_para, 1); double bsfs_diff = Math.round((total_bs - total_fs) * 1000.0) / 1000.0; double rl_diff = Math.round((last_rl - first_rl) * 1000.0) / 1000.0; boolean checktrue = (bsfs_diff) == (rl_diff) ? true : false; check_para.add(String.valueOf(bsfs_diff) + " = " + String.valueOf(rl_diff)); addEmptyLine(check_para, 1); if (checktrue) { check_para.setSpacingBefore(20); check_para.add("OK"); } else { check_para.setSpacingBefore(20); check_para.add("Check Fail!"); } addEmptyLine(check_para, 1); check_para.add("_______________________________________________________"); subCatPart.add(check_para); Paragraph legend_para = new Paragraph("LEGEND:", subFont); addEmptyLine(legend_para, 2); legend_para.add("BS : Back Sight"); addEmptyLine(legend_para, 1); legend_para.add("IS : Intermediate Sight"); addEmptyLine(legend_para, 1); legend_para.add("FS : Fore Sight"); addEmptyLine(legend_para, 1); legend_para.add("HI : Height of Instrument"); addEmptyLine(legend_para, 1); legend_para.add("RL : Reduced Level"); subCatPart.add(legend_para); }