List of usage examples for com.itextpdf.text Rectangle Rectangle
public Rectangle(final float llx, final float lly, final float urx, final float ury)
Rectangle
-object. From source file:com.github.wolfposd.imsqti2pdf.PDFCreator.java
License:Open Source License
public void createPDF(String outputFile, ArrayList<Question> qlist, boolean showCorrectAnswer, PageCounter pagecounter, int maximumPageNumber, String inputFolder) throws DocumentException, IOException { _inputFolder = inputFolder;/*ww w . j a v a 2 s . c o m*/ Document document = new Document(PageSize.A4, 50, 50, 70, 50); PdfWriter pdfwriter = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); pdfwriter.setBoxSize("art", new Rectangle(36, 54, 559, 788)); pdfwriter.setPageEvent(new HeaderFooter(maximumPageNumber)); if (pagecounter != null) { pdfwriter.setPageEvent(pagecounter); } document.open(); Paragraph p = new Paragraph(); // p.setSpacingBefore(SPACING); p.setSpacingAfter(SPACING); p.setIndentationLeft(INDENTATION); writeQuestions(p, document, showCorrectAnswer, qlist); document.close(); }
From source file:com.iox.rms.mbean.UserBean.java
@SuppressWarnings("deprecation") private byte[] generateInvoiceForCustomerPurchase(CustomerProduct cp) { byte[] data = null; if (cp != null) { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {/* w ww. j a v a2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new HeaderFooter()); writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788)); if (!document.isOpen()) { document.open(); } document.setPageSize(PageSize.A4); document.addAuthor("AutoLife"); document.addCreationDate(); document.addCreator("AutoLife"); document.addSubject("Invoice"); document.addTitle("Purchase Invoice"); PdfPTable headerTable = new PdfPTable(3); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance() .getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "sattrak-logo.png"; PdfPCell c = new PdfPCell(Image.getInstance(logo)); c.setBorder(0); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph("INVOICE", font)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); font = new Font(helvetica, 10, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph("TRANSACTION REF. NO.: " + cp.getPurchaseTranRef(), font)); c.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); c.setBorder(0); headerTable.addCell(c); document.add(headerTable); font = new Font(helvetica, 12, Font.NORMAL | Font.BOLD); Paragraph p = new Paragraph("DETAILS", font); p.setAlignment(Paragraph.ALIGN_CENTER); document.add(p); PdfPTable pdfTable = new PdfPTable(3); font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("INITIATED DATE", font)); pdfTable.addCell(new Paragraph("PRODUCT", font)); pdfTable.addCell(new Paragraph("AMOUNT", font)); font = new Font(helvetica, 8, Font.NORMAL); pdfTable.addCell( new Paragraph(cp.getPurchaseTransaction().getTranInitDate().toLocaleString(), font)); pdfTable.addCell(new Paragraph(cp.getProductBooked().getDetails(), font)); pdfTable.addCell(new Paragraph("" + cp.getPurchasedAmount(), font)); document.add(pdfTable); document.close(); data = baos.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); } } return data; }
From source file:com.isa.firma.FirmaPDFController.java
public ByteArrayOutputStream firmar(PDFFirma infoFirma, InputStream pdfbase64) throws AppletException { try {// www . j a v a 2s. com System.out.println("Firma Controller::firmar"); PdfReader reader = new PdfReader(pdfbase64); ByteArrayOutputStream os = new ByteArrayOutputStream(); PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, true); PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); System.out.println("Pre definir apariencia..."); if (infoFirma.isApariencia()) { System.out.println("Insertando apriencia en documento..."); appearance.setSignatureGraphic(Image.getInstance(new URL(infoFirma.getRutaImagen()))); appearance.setRenderingMode(Utiles.getModoApariencia()); int numeroPagFirma = infoFirma.getHoja() == -1 ? reader.getNumberOfPages() : infoFirma.getHoja(); int cantidadFirmaActuales = reader.getAcroFields().getSignatureNames().size(); int[] coords = infoFirma.calcularCorrdenadasFirma(cantidadFirmaActuales, infoFirma.getAncho(), infoFirma.getLargo()); //llx, lly, urx, ury String v = Utiles.encodingString(infoFirma.getFirmante()); System.out.println("Post encoding: " + v); appearance.setLayer2Text(v); //appearance.setLayer2Text( infoFirma.getFirmante() ); appearance.setVisibleSignature(new Rectangle(coords[0], coords[1], coords[2], coords[3]), numeroPagFirma, "Id: " + IdGenerator.generate()); } ExternalSignature es = new PrivateKeySignature(infoFirma.getPk(), "SHA-256", infoFirma.getProvidername()); ExternalDigest digest = new BouncyCastleDigest(); MakeSignature.signDetached(appearance, digest, es, infoFirma.getChainCert(), null, null, null, 0, CryptoStandard.CMS); System.out.println("PDF Firmado correctamente."); return os; } catch (IOException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (DocumentException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (KeyStoreException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (UnrecoverableKeyException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (GeneralSecurityException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } }
From source file:com.isa.firma.pades.FirmaPDFController.java
public ByteArrayOutputStream firmar(PDFFirma infoFirma, InputStream pdfbase64) throws AppletException { try {/*from w w w.jav a2s .c o m*/ PdfReader reader = new PdfReader(pdfbase64); ByteArrayOutputStream os = new ByteArrayOutputStream(); PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, true); PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); if (infoFirma.isApariencia()) { System.out.println("Definiendo apariencia..."); appearance.setRenderingMode(Utiles.getModoApariencia()); if (!Utiles.getModoApariencia().equals(PdfSignatureAppearance.RenderingMode.DESCRIPTION)) { appearance.setSignatureGraphic(Image.getInstance(new URL(infoFirma.getRutaImagen()))); } int numeroPagFirma = infoFirma.getHoja() == -1 ? reader.getNumberOfPages() : infoFirma.getHoja(); int cantidadFirmaActuales = reader.getAcroFields().getSignatureNames().size(); int[] coords = infoFirma.calcularCorrdenadasFirma(cantidadFirmaActuales, infoFirma.getAncho(), infoFirma.getLargo()); System.out.println("firmante: " + infoFirma.getFirmante()); System.out.println("serie: " + infoFirma.getNroSerie()); //llx, lly, urx, ury appearance.setLayer2Text(infoFirma.generarTextoEnFirma()); appearance.setVisibleSignature(new Rectangle(coords[0], coords[1], coords[2], coords[3]), numeroPagFirma, "Id: " + IdGenerator.generate()); } ExternalSignature es = new PrivateKeySignature(infoFirma.getPk(), "SHA-256", infoFirma.getProvidername()); ExternalDigest digest = new BouncyCastleDigest(); MakeSignature.signDetached(appearance, digest, es, infoFirma.getChainCert(), null, null, null, 0, CryptoStandard.CMS); System.out.println("PDF Firmado correctamente."); return os; } catch (IOException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (DocumentException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (KeyStoreException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (UnrecoverableKeyException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } catch (GeneralSecurityException ex) { Logger.getLogger(FirmaPDFController.class.getName()).log(Level.SEVERE, null, ex); throw new AppletException(UtilesMsg.ERROR_FIRMANDO_DOCUMENTO, null, ex.getCause()); } }
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
@Override public void onOpenDocument(PdfWriter writer, Document document) { PdfTemplate pgTpl = writer.getDirectContent().createTemplate(100, 100); pgTpl.setBoundingBox(new Rectangle(-20, -20, 100, 100)); ThreadHelper.set("_pageTpl_", pgTpl); }
From source file:com.maxl.java.amikodesk.SaveBasket.java
License:Open Source License
public void generatePdf(Author author, String filename, String type) { // A4: 8.267in x 11.692in => 595.224units x 841.824units (72units/inch) // marginLeft, marginRight, marginTop, marginBottom Document document = new Document(PageSize.A4, 50, 50, 80, 50); try {/*from w w w. jav a 2 s . c o m*/ if (m_shopping_basket.size() > 0) { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); writer.setBoxSize("art", new Rectangle(50, 50, 560, 790)); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); document.open(); PdfContentByte cb = writer.getDirectContent(); document.addAuthor("ywesee GmbH"); document.addCreator("AmiKo for Windows"); document.addCreationDate(); // Logo String logoImageStr = m_prefs.get(LogoImageID, Constants.IMG_FOLDER + "empty_logo.png"); File logoFile = new File(logoImageStr); if (!logoFile.exists()) logoImageStr = Constants.IMG_FOLDER + "empty_logo.png"; Image logo = Image.getInstance(logoImageStr); logo.scalePercent(30); logo.setAlignment(Rectangle.ALIGN_RIGHT); document.add(logo); document.add(Chunk.NEWLINE); // Bestelladresse // --> String bestellAdrStr = m_prefs.get(BestellAdresseID, m_rb.getString("noaddress1")); String bestellAdrStr = getAddressAsString(BestellAdresseID); Paragraph p = new Paragraph(12); // p.setIndentationLeft(60); p.add(new Chunk(bestellAdrStr, font_norm_10)); document.add(p); document.add(Chunk.NEWLINE); // Title p = new Paragraph(m_rb.getString("order"), font_bold_16); document.add(p); // Date DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); Date date = new Date(); p = new Paragraph(m_rb.getString("date") + ": " + dateFormat.format(date), font_bold_10); p.setSpacingAfter(20); document.add(p); // document.add(Chunk.NEWLINE); // Add addresses (Lieferadresse + Rechnungsadresse) /* --> OLD String lieferAdrStr = m_prefs.get(LieferAdresseID, m_rb.getString("noaddress2")); String rechnungsAdrStr = m_prefs.get(RechnungsAdresseID, m_rb.getString("noaddress3")); */ // --> NEW String lieferAdrStr = getAddressAsString(LieferAdresseID); String rechnungsAdrStr = getAddressAsString(RechnungsAdresseID); PdfPTable addressTable = new PdfPTable(new float[] { 1, 1 }); addressTable.setWidthPercentage(100f); addressTable.getDefaultCell().setPadding(5); addressTable.setSpacingAfter(5f); addressTable.addCell(getStringCell(m_rb.getString("shipaddress"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell(getStringCell(m_rb.getString("billaddress"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell( getStringCell(lieferAdrStr, font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell( getStringCell(rechnungsAdrStr, font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); document.add(addressTable); document.add(Chunk.NEWLINE); // Add shopping basket if (type.equals("specific")) document.add(getShoppingBasketForAuthor(author, cb)); else if (type.equals("all")) document.add(getFullShoppingBasket(cb, "all")); else if (type.equals("rest")) document.add(getFullShoppingBasket(cb, "rest")); LineSeparator separator = new LineSeparator(); document.add(separator); } } catch (IOException e) { } catch (DocumentException e) { } document.close(); // System.out.println("Saved PDF to " + filename); }
From source file:com.mycompany.mavenproject1.SubmitForm.java
public void extractFromPdf(String src, String dest) throws DocumentException, IOException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PushbuttonField button = new PushbuttonField(stamper.getWriter(), new Rectangle(36, 700, 112, 730), "get"); //stamper.getWriter().addJavaScript(Utilities.readFileToString(RESOURCE)); button.setText("SAVE My INFO"); button.setBackgroundColor(new GrayColor(0.7f)); button.setVisibility(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT); PdfFormField submit = button.getField(); /*//from ww w .ja v a 2s .c o m button.setBackgroundColor(new GrayColor(0.7f)); button.setVisibility(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT); */ //PdfFormField pull_data = upload_info.getField(); // pull_data.setAction(PdfAction.javaScript(Utilities.readFileToString(submit_button_script), stamper.getWriter())); stamper.getWriter().addJavaScript(Utilities.readFileToString(checkbox)); stamper.getWriter().addJavaScript(Utilities.readFileToString(upload_info)); //PushbuttonField submitButton=stamper.getAcroFields().getNewPushbuttonFromField("UseSavedInfo"); //PdfFormField field=submitButton.getField(); //field.setAction(PdfAction.javaScript("app.alert('hello')" ,stamper.getWriter())); /* PushbuttonField useMySavedInfo = new PushbuttonField( stamper.getWriter(), new Rectangle(36, 1000, 559, 806), "MySavedInfo" ); useMySavedInfo.setText("Upload info"); useMySavedInfo.setBackgroundColor(new GrayColor(0.7f)); useMySavedInfo.setVisibility(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT); PdfFormField extractInfo=useMySavedInfo.getField(); */ // extractInfo.setAction(PdfAction.javaScript("alert('hello')", stamper.getWriter())); // extractInfo.setAction(PdfAction.); //stamper. /* AcroFields fields = stamper.getAcroFields(); PushbuttonField submitButton=fields.getNewPushbuttonFromField("SubmitForm"); */ //System.out.println(submitButton.getAppearance().getHeight()); //System.out.println(submitButton.getAppearance().getWidth()); //System.out.println(submitButton.getAppearance()); //submitButton //submitButton.getField().get //submitButton.getWriter().setAdditionalAction(, PdfAction.javaScript("app.alert('os')",stamper.getWriter())); //submitButton.getWriter().setAdditionalAction(PdfName., action); //PdfFormField sb=submitButton.getField(); //sb.setAction(PdfAction.javaScript("app.alert('test')", stamper.getWriter())); // sumbitInfo.setAction(PdfAction.javaScript("app.alert('test')", stamper.getWriter())); //submit.setAction(PdfAction.javaScript("app.alert('test')", stamper.getWriter())); //PushbuttonField useInfo = fields.getNewPushbuttonFromField("UseSavedInfo"); //PdfAnnotation getInfo=useInfo.getField(); //getInfo.setAction(PdfAction.javaScript("app.alert('action!')", stamper.getWriter())); // ffield.SetAdditionalActions(PdfName.E, PdfAction("app.alert('action!')")); AcroFields fields = stamper.getAcroFields(); // PushbuttonField saveInfo = fields.getNewPushbuttonFromField("SaveInfo"); // PdfFormField fd=saveInfo.getField(); //fd.setAction(PdfAction.createSubmitForm("http://127.0.0.1/index.php",null,PdfAction.SUBMIT_HTML_FORMAT)); //PdfAppearance pa =saveInfo.getAppearance(); // pa.setAction(PdfAction.createSubmitForm("http://127.0.0.1/index.php",null,PdfAction.SUBMIT_HTML_FORMAT), 0, 0, 0, 0); Set<String> fldNames = fields.getFields().keySet(); //AcroFields fields = stamper.getAcroFields(); for (String fldName : fldNames) { System.out.println(fldName + ": " + fields.getField(fldName)); } //submit.setAdditionalAction(PdfAction.javaScript(Utilities.readFileToString(submit_button_script), stamper.getWriter())); //http://www.mycrewid.com/Alexander/index.php //submit.setAction(PdfAction.createSubmitForm( // "http://127.0.0.1/index.php", null, // PdfAction.SUBMIT_HTML_FORMAT)); submit.setAction( PdfAction.javaScript(Utilities.readFileToString(submit_button_script), stamper.getWriter())); stamper.addAnnotation(submit, 1); stamper.close(); //PdfAction.javaScript("this.getField('FirstName').value=util.printd(\"dd mmmm yyyy\",new Date())",stamper.getWriter()); //stamper.addAnnotation(submitButton, 1); //stamper.addAnnotation(sb,1); // submit.setAdditionalActions(PdfName.E, PdfAction.javaScript(Utilities.readFileToString(submit_button_script),stamper.getWriter())); }
From source file:com.pdi.util.PdfGenerator.java
public static void generarPresupuesto(String lugar, Date fecha, float cantidad, String tipo, Cliente cliente, float precio, Aliado aliado, String path) { try {/*from ww w .ja v a 2 s .co m*/ NEGRITA_12_VERDE.setColor(145, 189, 57); long miliSemana = System.currentTimeMillis() + (86400 * 7 * 1000); Date vtoPresup = new Date(miliSemana); float precioPers = precio / cantidad; int precioTotalInt = Math.round(precio); int precioPersInt = Math.round(precioPers); int cantPersonasInt = Math.round(cantidad); //Referencia al objeto Doc Document document = new Document(PageSize.A4, //Dimensiones 36, //margIzq 36, //margDer 36, //margenSup 36); // margenInf //Creamos el archivo fisico FileOutputStream salida = new FileOutputStream(path); //Referencia e inicializacion del objeto que "escribe" el PDF PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); //Imagen Logo Image logoPDI = Image.getInstance("Logo PDI.png"); logoPDI.scaleToFit(215, 205); logoPDI.setAlignment(Chunk.ALIGN_LEFT); //image.setAbsolutePosition(200, 200); //Imagen QR Image qr = Image.getInstance("QR PDI.png"); qr.scaleToFit(211, 165); qr.setAbsolutePosition(295, PageSize.A4.getHeight() - 390); //Parrafo info evento Paragraph infoEvento = new Paragraph(); infoEvento.add(new Chunk("Informacin del Evento", NEGRITA_SUB_12)); infoEvento.add(Chunk.NEWLINE); infoEvento.add(negritaNormal("Solicitante: ", cliente.toString())); infoEvento.add(negritaNormal("Evento: ", tipo)); infoEvento.add(negritaNormal("Cantidad de personas: ", Integer.toString(cantPersonasInt))); infoEvento.add(negritaNormal("Fecha: ", General.formatoFecha.format(fecha))); infoEvento.add(negritaNormal("Lugar: ", lugar)); infoEvento.add(Chunk.NEWLINE); infoEvento.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Modalidad del Servicio Paragraph modalidadServicio = new Paragraph(); modalidadServicio.add(new Chunk("Modalidad Servicio Integral", NEGRITA_SUB_12)); modalidadServicio.add(Chunk.NEWLINE); modalidadServicio.add(new Chunk("Nuestro servicio incluye la totalidad de lo referido a" + " los elementos necesarios para el despacho de bebidas: Barras, Bartenders," + " Artculos de Coctelera, Insumos de calidad para los tragos y Mucha Buena Onda." + " Con esta modalidad aseguramos la expedicin de " + "los tragos desde las 00hs hasta las 05hs, para que se desentiendan del asunto " + "y disfruten al mximo.", NORMAL_12)); modalidadServicio.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Ver Carta Paragraph verCarta = new Paragraph(); verCarta.add(negritaNormal("\u2022 Carta de Tragos: ", "Ver archivo adjunto.")); verCarta.setIndentationLeft(20); verCarta.add(Chunk.NEWLINE); verCarta.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Titulo Info Contratacion Paragraph infoContratacionTitulo = new Paragraph(); infoContratacionTitulo.add(new Chunk("Informacin de Contratacin", NEGRITA_SUB_12)); infoContratacionTitulo.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Inf de Contratacion Paragraph infoContratacion = new Paragraph(); infoContratacion.add(negritaNormal("\u2022 Mtodo de contratacin y reserva de la fecha: ", "A travs de contrato firmado por ambas partes. ")); Phrase lineaCosto = new Phrase(); lineaCosto.add(new Chunk("\u2022 Costo: ", NEGRITA_12)); lineaCosto.add(new Chunk("$" + Integer.toString(precioPersInt) + " ", NEGRITA_14)); lineaCosto.add(new Chunk("por persona ", NEGRITA_12)); lineaCosto.add(new Chunk("(Total: $" + Integer.toString(precioTotalInt) + ")", NEGRITA_14)); infoContratacion.add(lineaCosto); infoContratacion.add(Chunk.NEWLINE); infoContratacion.add(negritaNormal("\u2022 Forma de Pago : ", "50% al momento de la firma del contrato y 50% como mximo una semana antes del evento. ")); infoContratacion.add(Chunk.NEWLINE); infoContratacion.setIndentationLeft(20); infoContratacion.setFirstLineIndent(0); infoContratacion.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Despedida Paragraph despedida = new Paragraph(); despedida.add(new Phrase("Quedamos al aguardo de tus comentarios,", NEGRITA_14)); despedida.add(Chunk.NEWLINE); despedida.add(new Phrase("Muchas Gracias.", NEGRITA_14)); despedida.add(Chunk.NEWLINE); despedida.add(Chunk.NEWLINE); despedida.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Firma Paragraph firma = new Paragraph(); firma.add(new Phrase("Piel de Iguana Tragos.-", NEGRITA_CUR_14)); firma.add(Chunk.NEWLINE); firma.add(new Phrase("Cel.: 3462-15337860", NEGRITA_12_VERDE)); firma.setAlignment(Paragraph.ALIGN_RIGHT); float llxLink = 279; float llyLink = PageSize.A4.getHeight() - 145; float anchoLink = 199; float altoLink = 16; //Link al facebook URL urlPDI = new URL("https://www.facebook.com/pieldeiguanatragos.vt"); PdfAction irAlFace = new PdfAction(urlPDI); Rectangle linkLocation = new Rectangle(llxLink, llyLink, llxLink + anchoLink, llyLink + altoLink); PdfAnnotation link = PdfAnnotation.createLink(writer, linkLocation, PdfAnnotation.HIGHLIGHT_NONE, irAlFace); link.setBorder(new PdfBorderArray(0, 0, 0)); writer.addAnnotation(link); //Espacios Vacios Paragraph dosEspacios = new Paragraph(); dosEspacios.add(Chunk.NEWLINE); dosEspacios.add(Chunk.NEWLINE); //Hay que abrir el Documento, llenarlo con los elemntos creados //en el orden que queremos y cerrarlo document.open(); PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); Phrase recuadro = new Phrase(); recuadro.add(new Chunk("Piel de Iguana Tragos", NEGRITA_SUB_14)); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("Servicio de tragos para eventos", NEGRITA_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("\"Piel de Iguana, para que tu noche nica sea inigualable.\"", NORMAL_CUR_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); Image logoFB = Image.getInstance("Icono FB.png"); logoFB.scaleToFit(13, 13); recuadro.add(new Chunk(logoFB, 0, -3)); recuadro.add(new Chunk("/pieldeiguanatragos.vt -> Click Aqu!", NORMAL_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("Vencimiento del Prepuesto " + General.formatoFecha.format(vtoPresup), NORMAL_SUB_12)); float llx = 279; float lly = PageSize.A4.getHeight() - 185; float ancho = 228; float alto = 150; ct.setSimpleColumn(recuadro, //Texto llx, //punta inf izquierda (x) lly, //punta inf izquierda (y) PageSize.A4.getHeight() - 185 llx + ancho, //ancho del cuadro lly + alto, // alto del cuadro 15, //espaciado Element.ALIGN_LEFT // Alineacion ); ct.go(); document.add(logoPDI); document.add(qr); document.add(dosEspacios); document.add(infoEvento); document.add(modalidadServicio); document.add(verCarta); document.add(infoContratacionTitulo); document.add(infoContratacion); document.add(despedida); document.add(firma); document.close(); System.out.println("Archivo creado"); int rta = JOptionPane.showConfirmDialog(VentanaMaestra.eventosCurrent, "Se guard el presupesto en:\n" + path + "\nDesea abrirlo?", "Presupuesto guardado", JOptionPane.YES_NO_OPTION); if (rta == JOptionPane.YES_OPTION) { if (Desktop.isDesktopSupported()) { try { File myFile = new File(path); Desktop.getDesktop().open(myFile); } catch (IOException ex) { JOptionPane.showMessageDialog(VentanaMaestra.eventosCurrent, "No se puede abrir el archivo. Ubiquelo en su equipo" + "y abralo manualmente.", "Error al abrir el archivo", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(VentanaMaestra.eventosCurrent, "No se puede abrir el archivo. Ubiquelo en su equipo" + "y abralo manualmente.", "Error al abrir el archivo", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException ex) { System.out.println("Error: " + ex.toString()); } catch (DocumentException ex) { System.out.println("Error: " + ex.toString()); } catch (IOException ex) { System.out.println("Error: " + ex.toString()); } }
From source file:com.planfeed.services.MeetingServiceImpl.java
License:Apache License
public ByteArrayOutputStream getActa(String meetingId) throws Exception { Meeting meeting;// w w w .j a v a2 s . com try { meeting = this.getMeeting(meetingId); } catch (Exception e) { throw new MeetingNotFound(); } Document document = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter docWriter = null; HeaderFooter event = new HeaderFooter(meeting.getDate()); docWriter = PdfWriter.getInstance(document, baosPDF); docWriter.setBoxSize("art", new Rectangle(36, 54, 559, 788)); docWriter.setPageEvent(event); document.open(); //metadata document.addTitle(meeting.getTitle() + " Acta"); document.add(new Paragraph(" ")); //Title Paragraph title = new Paragraph("Acta of " + meeting.getTitle(), titleFont); title.setAlignment(Element.ALIGN_CENTER); addEmptyLine(title, 1); document.add(title); //Description Paragraph descriptionPar = new Paragraph(); descriptionPar.add(new Paragraph("Description", titlePointFont)); descriptionPar.add(new Paragraph(meeting.getDescription(), textFont)); addEmptyLine(descriptionPar, 1); document.add(descriptionPar); //Points int index = 1; for (PointOfAgenda point : meeting.getAgenda()) { Paragraph pointPar = new Paragraph(); pointPar.add(new Paragraph(index + ". " + point.getName(), titlePointFont)); pointPar.add(new Paragraph(point.getComment(), textFont)); addEmptyLine(pointPar, 2); document.add(pointPar); index += 1; } document.close(); return baosPDF; }
From source file:com.softwaremagico.tm.pdf.complete.elements.TableBorderEvent.java
License:Open Source License
@Override public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvas) {/* w w w. ja v a 2s.c om*/ float width[] = widths[0]; float x1 = width[0]; float x2 = width[width.length - 1]; float y1 = heights[0]; float y2 = heights[heights.length - 1]; PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; Rectangle rect1 = new Rectangle(x1, y1, x2, y2); rect1.setBorder(Rectangle.BOX); rect1.setBorderWidth(2); cb.rectangle(rect1); cb.stroke(); }