List of usage examples for com.itextpdf.text Image setAbsolutePosition
public void setAbsolutePosition(final float absoluteX, final float absoluteY)
Image
. From source file:es.sm2.openppm.front.utils.DocumentUtils.java
License:Open Source License
/** * /*from w w w . java 2s . com*/ * @param pagActual * @param pagTotal * @param headerImg * @param footerImg * @param reader * @param stamper * @param idioma * @throws DocumentException * @throws IOException */ private static void setHeaderFooter(int pagActual, int pagTotal, Image headerImg, Image footerImg, PdfReader reader, PdfStamper stamper, ResourceBundle idioma) throws DocumentException, IOException { PdfContentByte content = stamper.getUnderContent(pagActual); content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 8); headerImg.setAbsolutePosition(74f, 745f); content.addImage(headerImg); footerImg.setAbsolutePosition(75f, 20f); content.addImage(footerImg); content.beginText(); content.showTextAligned(Element.ALIGN_BOTTOM, "_____________________________________________________________________________________________________", 75f, 55f, 0f); content.showTextAligned(Element.ALIGN_BOTTOM, "2010 OPEN PPM - Projet Portfolio Management. (Open PPM)", 75f, 45f, 0f); content.showTextAligned(Element.ALIGN_BOTTOM, "www.sourceforce.net/openppm", 75f, 35f, 0f); content.showTextAligned(Element.ALIGN_BOTTOM, new ParamResourceBundle("pdf.pagination", pagActual, pagTotal).toString(idioma), 475f, 45f, 0f); content.endText(); content.stroke(); }
From source file:Evento.action.ZapisDoPdfAction.java
License:Apache License
public void createPDF(String[] imgURL, String place, String album) throws DocumentException { Document document = new Document(); Rectangle pageSize = new Rectangle(szerokosc, wysokosc); document.setPageSize(pageSize);/*from ww w.java 2 s. c o m*/ try { PdfWriter.getInstance(document, new FileOutputStream(new File(place, "nowy.pdf"))); document.open(); Image tlo = Image.getInstance(new URL(zdjecieTla)); tlo.setAbsolutePosition(0f, 0f); document.add(tlo); Paragraph preface = new Paragraph(album, new Font(FontFamily.HELVETICA, 72, Font.BOLDITALIC, new BaseColor(255, 255, 255))); preface.setAlignment(Element.ALIGN_CENTER); document.add(preface); document.newPage(); for (int i = 0; i < imgURL.length; i++) { Image tlo2 = Image.getInstance(new URL(zdjecieTla)); tlo2.setAbsolutePosition(0f, 0f); document.add(tlo2); Image image2 = Image.getInstance(new URL(imgURL[i])); if (szerokosc * 1.5f <= image2.getWidth() || wysokosc * 1.5f <= image2.getHeight()) { image2.scaleAbsolute(image2.getWidth() * 0.25f, image2.getHeight() * 0.25f); image2.setAbsolutePosition(szerokosc / 2f - (image2.getWidth() * 0.25f) / 2, wysokosc / 2 - (image2.getHeight() * 0.25f) / 2); } else if ((szerokosc * 0.8f <= image2.getWidth() || wysokosc * 0.8f <= image2.getHeight()) && (szerokosc * 1.2f >= image2.getWidth() || wysokosc * 1.2f >= image2.getHeight())) { image2.scaleAbsolute(image2.getWidth() * 0.8f, image2.getHeight() * 0.8f); image2.setAbsolutePosition(szerokosc / 2f - (image2.getWidth() * 0.8f) / 2, wysokosc / 2 - (image2.getHeight() * 0.8f) / 2); } else if ((szerokosc * 0.4f >= image2.getWidth() || wysokosc * 0.4f >= image2.getHeight()) && (szerokosc * 0.7f <= image2.getWidth() || wysokosc * 0.7f <= image2.getHeight())) { image2.scaleAbsolute(image2.getWidth() * 1.4f, image2.getHeight() * 1.4f); image2.setAbsolutePosition(szerokosc / 2f - (image2.getWidth() * 1.4f) / 2, wysokosc / 2 - (image2.getHeight() * 1.4f) / 2); } else { image2.scaleAbsolute(image2.getWidth(), image2.getHeight()); image2.setAbsolutePosition(szerokosc / 2f - (image2.getWidth()) / 2, wysokosc / 2 - (image2.getHeight()) / 2); } for (int k = 0; k <= 1000; k++) ; for (int j = 0; j <= 1000; j++) ; document.add(image2); document.newPage(); } document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:eyeofthetiger.utils.PDFDossardGenerator.java
public void createPdf(List<Participant> participants, OutputStream out) throws IOException, DocumentException { sortParticipants(participants);//from www . jav a 2 s .c o m Document document = new Document(PageSize.A4.rotate()); float margin = CentimeterToUserSpace(marginCm); document.setMargins(margin, margin, margin, margin); PdfWriter writer = PdfWriter.getInstance(document, out); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfReader pdfBackgroundReader = null; PdfImportedPage backgroundPage = null; if (pdfBackground != null && (new File(pdfBackground)).exists() && (new File(pdfBackground)).isFile()) { pdfBackgroundReader = new PdfReader(pdfBackground); backgroundPage = writer.getImportedPage(pdfBackgroundReader, 1); } float documentTop = document.top(); float documentBottom = document.bottom(); float documentHeight = documentTop - documentBottom; float left = document.left(); float right = document.right(); float width = right - left; float height = documentTop - documentBottom; //cb.rectangle(left, documentBottom, width, documentHeight); //cb.stroke(); boolean logoLeftExist = (new File(logoLeft)).exists() && (new File(logoLeft)).isFile(); boolean logoRightExist = (new File(logoRight)).exists() && (new File(logoRight)).isFile(); float imgLeftRight = left; float imgLeftBottom = documentTop; float imgRightLeft = right; float imgRighBottom = documentTop; Image imgLeft = null; Image imgRight = null; if (exportLogos) { if (logoLeftExist) { imgLeft = Image.getInstance(logoLeft); float h = imgLeft.getHeight(); float w = imgLeft.getWidth(); float nw = width * logoLeftWidth; float nh = (h / w) * nw; imgLeft.scaleAbsolute(nw, nh); //img.scaleAbsoluteHeight(img.getScaledWidth() / xyRatio); imgLeft.setAbsolutePosition(left, documentTop - imgLeft.getScaledHeight()); //cb.addImage(img); imgLeftRight = imgLeft.getAbsoluteX() + imgLeft.getScaledWidth(); imgLeftBottom = imgLeft.getAbsoluteY(); } if (logoRightExist) { imgRight = Image.getInstance(logoRight); float h = imgRight.getHeight(); float w = imgRight.getWidth(); float nw = width * logoRightWidth; float nh = (h / w) * nw; imgRight.scaleAbsolute(nw, nh); imgRight.setAbsolutePosition(right - imgRight.getScaledWidth(), documentTop - imgRight.getScaledHeight()); //cb.addImage(imgRight); imgRightLeft = imgRight.getAbsoluteX(); imgRighBottom = imgRight.getAbsoluteY(); } } float nameHeightPercent = 0.35f; float groupHeightPercent = 0.25f; float nameTop = documentTop; float nameBottom = nameTop; if (exportName) { nameBottom = nameTop - (documentHeight * nameHeightPercent); } float groupeTop = nameBottom; float groupeBottom = nameBottom; if (exportGroup) { groupeBottom = groupeTop - (documentHeight * groupHeightPercent); } float barcodeTop = groupeBottom; float barcodeBottom = documentBottom; ColumnText columnText; for (Participant participant : participants) { if (backgroundPage != null) { //cb.addTemplate(backgroundPage, 1f, 0, 0, 1, 0, 0); //TODO cb.addTemplate(backgroundPage, 0, 0); } float nameFontSize = 65f; float groupFontSize = 45f; float renseignementFontSize = 35f; if (imgLeft != null) { cb.addImage(imgLeft); } if (imgRight != null) { cb.addImage(imgRight); } if (exportName) { columnText = new ColumnText(cb); columnText.setAlignment(Rectangle.ALIGN_CENTER); if (imgLeftRight != -1 && imgLeftBottom != -1) { float[] leftBorder = null; if (imgLeftBottom < nameBottom) { leftBorder = new float[] { imgLeftRight, nameTop, imgLeftRight, nameBottom, left, nameBottom }; } else { leftBorder = new float[] { imgLeftRight, nameTop, imgLeftRight, imgLeftBottom, left, imgLeftBottom, left, nameBottom }; } float[] rightBorder = null; if (imgRighBottom < nameBottom) { rightBorder = new float[] { imgRightLeft, nameTop, imgRightLeft, nameBottom, right, nameBottom }; } else { rightBorder = new float[] { imgRightLeft, nameTop, imgRightLeft, imgRighBottom, right, imgRighBottom, right, nameBottom }; } columnText.setColumns(leftBorder, rightBorder); } else { columnText.setSimpleColumn(left, nameTop, right, nameBottom); } //cb.rectangle(left, nameBottom, width, (nameTop - nameBottom)); //cb.stroke(); columnText.setExtraParagraphSpace(0f); columnText.setAdjustFirstLine(false); columnText.setIndent(0); String txt = participant.getNom().toUpperCase() + " " + participant.getPrenom(); float previousPos = columnText.getYLine(); columnText.setLeading(nameFontSize); columnText.setText(createCleanPhrase(txt, nameFontSize, true)); while (nameFontSize > 1 && ColumnText.hasMoreText(columnText.go(true))) { nameFontSize = nameFontSize - 0.5f; columnText.setLeading(nameFontSize); columnText.setText(createCleanPhrase(txt, nameFontSize, true)); columnText.setYLine(previousPos); } columnText.setLeading(nameFontSize); columnText.setText(createCleanPhrase(txt, nameFontSize, true)); columnText.setYLine(previousPos); columnText.go(false); } if (exportGroup) { columnText = new ColumnText(cb); columnText.setAlignment(Rectangle.ALIGN_CENTER); columnText.setSimpleColumn(document.left(), groupeTop, document.right(), groupeBottom); float groupeHeight = groupeTop - groupeBottom; //cb.rectangle(document.left(), groupeTop - groupeHeight, document.right() - document.left(), groupeHeight); //cb.stroke(); columnText.setExtraParagraphSpace(0f); columnText.setAdjustFirstLine(false); columnText.setIndent(0); columnText.setFollowingIndent(0); String txt1 = participant.getGroupe(); String txt2 = exportRenseignement ? "\n" + participant.getRenseignements() : null; float previousPos = columnText.getYLine(); columnText.setText(null); columnText.setLeading(groupFontSize); columnText.addText(createCleanPhrase(txt1, groupFontSize, true)); columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false)); while (groupFontSize > 1 && ColumnText.hasMoreText(columnText.go(true))) { groupFontSize = groupFontSize - 0.5f; renseignementFontSize = renseignementFontSize - 0.5f; columnText.setText(null); columnText.setLeading(groupFontSize); columnText.addText(createCleanPhrase(txt1, groupFontSize, true)); columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false)); columnText.setYLine(previousPos); } columnText.setText(null); columnText.setLeading(groupFontSize); columnText.addText(createCleanPhrase(txt1, groupFontSize, true)); columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false)); columnText.setYLine(previousPos); columnText.go(false); } { columnText = new ColumnText(cb); float topMargin = 12f; columnText.setSimpleColumn(left, barcodeTop - topMargin, right, barcodeBottom); float barcodeHeight = (barcodeTop - topMargin) - barcodeBottom; //cb.rectangle(left, barcodeTop - barcodeHeight, width, barcodeHeight); //cb.stroke(); columnText.setExtraParagraphSpace(0f); columnText.setAdjustFirstLine(false); columnText.setIndent(0); float previousPos = columnText.getYLine(); columnText.setText(null); columnText.addElement(createCleanBarcode(cb, participant.getNumero(), width, barcodeHeight)); columnText.go(false); } document.newPage(); } document.close(); if (pdfBackgroundReader != null) { pdfBackgroundReader.close(); } }
From source file:fc.extensions.itext.Writer.java
License:MIT License
public void writeBarcode(String barcode, float leftX, float bottomY, float scalePercent, boolean isShowCode) throws Exception { Barcode39 code39 = new Barcode39(); code39.setStartStopText(false);/*from w w w . ja v a2 s .c o m*/ code39.setTextAlignment(PdfContentByte.ALIGN_LEFT); if (!isShowCode) { code39.setFont(null); } code39.setCode(barcode); Image image = code39.createImageWithBarcode(pdfWriterCB, this.baseColor, this.baseColor); image.setAbsolutePosition(leftX, bottomY); image.scalePercent(scalePercent); pdfWriterCB.addImage(image); }
From source file:fc.extensions.itext.Writer.java
License:MIT License
public void writeImage(String imagePath, float leftX, float bottomY, float scalePercent) throws Exception { Image image = Image.getInstance(imagePath); image.setAbsolutePosition(leftX, bottomY); if (scalePercent > 0F) { image.scalePercent(scalePercent); }/* w w w . j a v a 2 s .c o m*/ pdfWriterCB.addImage(image); }
From source file:fyp.JavaWritePDF.java
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); // read source file PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); // create destination file stamper.insertPage(reader.getNumberOfPages() + 1, reader.getPageSizeWithRotation(1)); // insert new page Image img = Image.getInstance(IMG); // get instance of image file img.setAbsolutePosition(0, 350); stamper.getOverContent(2).addImage(img); // insert image to new page stamper.close(); // close stamper File delfile = new File(SRC); delfile.delete(); // delete source file respiratorytest.success();// w w w . j av a 2s .co m }
From source file:fyp.JavaWritePDF.java
public void manipulatePdf2(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.insertPage(reader.getNumberOfPages() + 1, reader.getPageSizeWithRotation(1)); stamper.insertPage(reader.getNumberOfPages() + 1, reader.getPageSizeWithRotation(1));// create a second new page Image img = Image.getInstance(IMG); Image img2 = Image.getInstance(IMG2); img.setAbsolutePosition(0, 350); img2.setAbsolutePosition(0, 350);//www . ja v a 2s. com stamper.getOverContent(2).addImage(img); stamper.getOverContent(3).addImage(img2); // add the second sessions image to the new page stamper.close(); File delfile = new File(SRC); delfile.delete(); respiratorytest.success(); }
From source file:GestoSAT.Albaran.java
License:Open Source License
public String albaran2PDF(int id) { try {// w w w. j ava 2 s .c o m String arch = "Albaran" + (new Date()).getTime() + ".pdf"; Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream("/TomEE/webapps/ROOT/descargables/" + arch)); DecimalFormat df = new DecimalFormat("0.00"); doc.open(); File f = new File("logo"); if (f.exists()) { Image img = Image.getInstance("logo"); img.setAbsolutePosition(50, 735); img.scaleAbsolute(50, 50); doc.add(img); Paragraph p = new Paragraph(" "); p.setLeading((float) 75); doc.add(p); } doc.add(new Paragraph("ALBAR?N")); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Datos empresa")); Oficina ofi = this.getGestoSAT().getEmpleado().getOficina(); doc.add(new Paragraph( ofi.getProvincia() + " " + ofi.getPoblacion() + " " + ofi.getCalle() + " " + ofi.getNumero())); doc.add(new Paragraph(ofi.getNombre())); doc.add(new Paragraph("NIF: " + ofi.getNif())); doc.add(new Paragraph("Tlf: " + ofi.getTlfFijo() + " " + ofi.getTlfMovil())); doc.add(new Paragraph("Fax: " + ofi.getFax())); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Datos de inters")); doc.add(new Paragraph( "Cliente: " + this.getCliente().getNombre() + " " + this.getCliente().getApellidos())); doc.add(new Paragraph("Concepto: " + this.concepto)); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Lugar de entrga:" + this.provincia + " " + this.poblacion + " " + this.calle + " " + this.escalera + " " + this.piso + " " + this.puerta)); doc.add(new Paragraph(" ")); float auxPrecio = 0; PdfPTable table = new PdfPTable(5); table.addCell("#"); table.addCell("Nombre"); table.addCell("Precio Ud / H"); table.addCell("Uds / H"); table.addCell("Total"); Iterator itTabla = this.materialUtilizado.entrySet().iterator(); while (itTabla.hasNext()) { Map.Entry aux = (Map.Entry) itTabla.next(); table.addCell(aux.getKey().toString()); table.addCell(((MaterialTrabajos) aux.getValue()).getStock().getNombre()); table.addCell(((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad() + ""); table.addCell(((MaterialTrabajos) aux.getValue()).getCantidad() + ""); auxPrecio += ((MaterialTrabajos) aux.getValue()).getCantidad() * ((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad(); table.addCell((((MaterialTrabajos) aux.getValue()).getCantidad() * ((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad()) + ""); } itTabla = this.trabajoRealizado.entrySet().iterator(); while (itTabla.hasNext()) { Map.Entry aux = (Map.Entry) itTabla.next(); table.addCell("*"); Trabajo tra = (Trabajo) aux.getValue(); table.addCell(tra.getEmpleado().getNombre() + " " + tra.getEmpleado().getApellidos()); table.addCell(tra.getEmpleado().getPrecioHora() + ""); table.addCell(tra.getHoras() + ""); auxPrecio += tra.getEmpleado().getPrecioHora() * tra.getHoras(); table.addCell((tra.getEmpleado().getPrecioHora() * tra.getHoras()) + ""); } doc.add(table); doc.add(new Paragraph("I.V.A: " + this.getGestoSAT().getIva() + "%")); doc.add(new Paragraph( "Total I.V.A: " + df.format((this.getGestoSAT().getIva() / (float) 100) * auxPrecio))); doc.add(new Paragraph( "Total: " + df.format(((this.getGestoSAT().getIva() / (float) 100) + 1) * auxPrecio))); doc.close(); if (this.fchEntrega == null) { this.fchEntrega = new Date(); if (this.getGestoSAT().entregaAlbaran(id, this)) return "descargables/" + arch; else return ""; } else return "descargables/" + arch; } catch (IOException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } catch (BadElementException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } catch (DocumentException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } }
From source file:GestoSAT.Entrada.java
License:Open Source License
public String entrada2PDF() { try {//from w w w . j a v a2 s .c o m String arch = "Entrada" + (new Date()).getTime() + ".pdf"; Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream("/TomEE/webapps/ROOT/descargables/" + arch)); doc.open(); File f = new File("logo"); // http://www.java2s.com/Tutorial/Java/0280__SWT/UseImageDatatocreateanewimage.htm if (f.exists()) { Image img = Image.getInstance("logo"); img.setAbsolutePosition(50, 735); img.scaleAbsolute(50, 50); doc.add(img); Paragraph p = new Paragraph(" "); p.setLeading((float) 75); doc.add(p); } doc.add(new Paragraph( "Cliente: " + this.getCliente().getNombre() + " " + this.getCliente().getApellidos())); if (this.incidencia.getClass().getName().equals("GestoSAT.Averia")) { doc.add(new Paragraph(" ")); doc.add(new Paragraph("APARATO")); doc.add(new Paragraph(" ")); Averia av = (Averia) this.incidencia; doc.add(new Paragraph("Problema: " + av.getMotivo())); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Tipo: " + av.getAparato().getTipo())); doc.add(new Paragraph("Marca: " + av.getAparato().getMarca())); doc.add(new Paragraph("Modelo: " + av.getAparato().getModelo())); doc.add(new Paragraph("NSerie: " + av.getAparato().getNumSerie())); doc.add(new Paragraph("Color: " + av.getAparato().getColor())); doc.add(new Paragraph("Observaciones: " + av.getAparato().getObservaciones())); } else { Cita cita = (Cita) this.incidencia; doc.add(new Paragraph(" ")); doc.add(new Paragraph("CITA")); doc.add(new Paragraph("Problema:" + cita.getMotivo())); doc.add(new Paragraph( "Direccin:" + cita.getPoblacion() + " " + cita.getCalle() + " " + cita.getNumero() + " " + cita.getEscalera() + " " + cita.getPiso() + " " + cita.getPuerta())); doc.add(new Paragraph("Obsevaciones:" + cita.getObservacionesDirrecion())); doc.add(new Paragraph(cita.getObservaciones())); } doc.close(); return "descargables/" + arch; } catch (Exception ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } }
From source file:GestoSAT.Factura.java
License:Open Source License
public String factura2PDF() { try {//from w ww .j ava 2s. c om String arch = "Factura" + (new Date()).getTime() + ".pdf"; Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream("/TomEE/webapps/ROOT/descargables/" + arch)); DecimalFormat df = new DecimalFormat("0.00"); doc.open(); File f = new File("logo"); if (f.exists()) { Image img = Image.getInstance("logo"); img.setAbsolutePosition(50, 735); img.scaleAbsolute(50, 50); doc.add(img); Paragraph p = new Paragraph(" "); p.setLeading((float) 75); doc.add(p); } doc.add(new Paragraph("FACTURA")); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Datos empresa")); Oficina ofi = this.getGestoSAT().getEmpleado().getOficina(); doc.add(new Paragraph( ofi.getProvincia() + " " + ofi.getPoblacion() + " " + ofi.getCalle() + " " + ofi.getNumero())); doc.add(new Paragraph(ofi.getNombre())); doc.add(new Paragraph("NIF: " + ofi.getNif())); doc.add(new Paragraph("Tlf: " + ofi.getTlfFijo() + " " + ofi.getTlfMovil())); doc.add(new Paragraph("Fax: " + ofi.getFax())); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Datos de inters")); doc.add(new Paragraph( "Cliente: " + this.getCliente().getNombre() + " " + this.getCliente().getApellidos())); doc.add(new Paragraph("Concepto: " + this.concepto)); doc.add(new Paragraph("Forma pago: " + this.formaPago)); doc.add(new Paragraph(" ")); doc.add(new Paragraph("Albaranes")); Iterator itAlbaranes = this.albaran.entrySet().iterator(); while (itAlbaranes.hasNext()) { Map.Entry auxAlbaranes = (Map.Entry) itAlbaranes.next(); // Leer albaranes float auxPrecio = 0; PdfPTable table = new PdfPTable(5); table.addCell("#"); table.addCell("Nombre"); table.addCell("Precio Ud / H"); table.addCell("Uds / H"); table.addCell("Total"); Iterator itTabla = ((Albaran) auxAlbaranes.getValue()).getMaterialUtilizado().entrySet().iterator(); while (itTabla.hasNext()) { Map.Entry aux = (Map.Entry) itTabla.next(); table.addCell(aux.getKey().toString()); table.addCell(((MaterialTrabajos) aux.getValue()).getStock().getNombre()); table.addCell(((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad() + ""); table.addCell(((MaterialTrabajos) aux.getValue()).getCantidad() + ""); auxPrecio += ((MaterialTrabajos) aux.getValue()).getCantidad() * ((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad(); table.addCell((((MaterialTrabajos) aux.getValue()).getCantidad() * ((MaterialTrabajos) aux.getValue()).getStock().getPrecioUnidad()) + ""); } itTabla = ((Albaran) auxAlbaranes.getValue()).getTrabajoRealizado().entrySet().iterator(); while (itTabla.hasNext()) { Map.Entry aux = (Map.Entry) itTabla.next(); table.addCell("*"); Trabajo tra = (Trabajo) aux.getValue(); table.addCell(tra.getEmpleado().getNombre() + " " + tra.getEmpleado().getApellidos()); table.addCell(tra.getEmpleado().getPrecioHora() + ""); table.addCell(tra.getHoras() + ""); auxPrecio += tra.getEmpleado().getPrecioHora() * tra.getHoras(); table.addCell((tra.getEmpleado().getPrecioHora() * tra.getHoras()) + ""); } doc.add(table); doc.add(new Paragraph("I.V.A: " + this.getGestoSAT().getIva() + "%")); doc.add(new Paragraph( "Total I.V.A: " + df.format((this.getGestoSAT().getIva() / (float) 100) * auxPrecio))); doc.add(new Paragraph( "Total: " + df.format(((this.getGestoSAT().getIva() / (float) 100) + 1) * auxPrecio))); doc.add(new Paragraph(" ")); } doc.add(new Paragraph(" ")); doc.add(new Paragraph("Tota factura: " + df.format(this.total))); doc.close(); return "descargables/" + arch; } catch (IOException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } catch (BadElementException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } catch (DocumentException ex) { Logger.getLogger(Entrada.class.getName()).log(Level.SEVERE, null, ex); return ""; } }