List of usage examples for com.lowagie.text Image getInstance
public static Image getInstance(Image image)
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setBarCode(Image logo) { PdfPCell celdaImg = null;/*from www . j a v a 2 s . co m*/ try { Image imagelogo = Image.getInstance(logo); celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setPadding(5); celdaImg.setHorizontalAlignment(Element.ALIGN_CENTER); } catch (Exception e) { celdaImg = null; } return celdaImg; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setLogoCarnet(String logo, int ancho, int alto) { PdfPCell celdaImg = null;/*from w w w . j a v a2 s . co m*/ try { Image imagelogo = Image.getInstance(logo); imagelogo.scaleAbsolute(ancho, alto); celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setPadding(0); celdaImg.setPaddingLeft(50); } catch (Exception e) { celdaImg = null; } return celdaImg; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static Image setMarcaAgua(String logo, int ancho, int alto) { try {/*from w w w .ja va2 s.com*/ Image imagelogo = Image.getInstance(logo); imagelogo.setTransparency(new int[] { 255, 255 }); imagelogo.setRotationDegrees(57); imagelogo.scaleAbsolute(ancho, alto); imagelogo.setAbsolutePosition(0, 30); return imagelogo; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPTable setCabecera(String logo, String titulo, String ruc, String subtitulo, String direccion, String sucursal) {/*from w ww .j a v a 2 s . c o m*/ PdfPTable encabezado = new PdfPTable(new float[] { 80f, 400f }); PdfPTable tbl_encab = new PdfPTable(1); Image imagelogo = null; try { imagelogo = Image.getInstance(logo); imagelogo.scaleAbsolute(150, 70); PdfPCell celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setPadding(0); encabezado.addCell(celdaImg); } catch (Exception e) { encabezado.addCell(""); } tbl_encab.addCell(Addons.setCeldaPDF(titulo, Font.HELVETICA, 13, Font.BOLD, Element.ALIGN_CENTER, 0)); tbl_encab.addCell(Addons.setCeldaPDF(direccion, Font.HELVETICA, 11, Font.NORMAL, Element.ALIGN_CENTER, 0)); if (ruc.compareTo("") != 0) { tbl_encab.addCell( Addons.setCeldaPDF("RUC: " + ruc, Font.HELVETICA, 11, Font.NORMAL, Element.ALIGN_CENTER, 0)); } tbl_encab.addCell(Addons.setCeldaPDF(subtitulo, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0)); encabezado.addCell(Addons.setCeldaPDF(tbl_encab, Element.ALIGN_CENTER, 0)); encabezado.addCell(Addons.setFilaBlanco(2, 6)); if (sucursal.compareTo("") != 0) { encabezado.addCell(Addons.setCeldaPDF("Sucursal: " + sucursal, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 2)); } encabezado.addCell(Addons.setCeldaPDF("Fecha de impresin: " + Fecha.getFecha("SQL"), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 2)); encabezado.addCell(Addons.setFilaBlanco(2, 4)); return encabezado; }
From source file:jsf.pdfLogo.java
/** * Creates a new instance of pdfLogo/* www . j a va2s . co m*/ */ public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; ServletContext servletContex = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContex.getRealPath(""); System.out.println("logo"); pdf.open(); String logo2 = "/images/logotyp.png"; img = Image.getInstance(logo + logo2); img.setAlignment(Image.ALIGN_CENTER); pdf.add(img); }
From source file:kinomaniak.mprimef.pdfLogo.java
/** * Creates a new instance of pdfLogo/*from www . j a va 2s . c om*/ */ public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; ServletContext servletContex = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContex.getRealPath(""); System.out.println("logo"); pdf.open(); String logo2 = "/images/logotyp.jpg"; img = Image.getInstance(logo + logo2); img.setAlignment(Image.ALIGN_CENTER); pdf.add(img); }
From source file:lmcpointofsalessystem.PDFCustomers.java
public PDFCustomers(String tblName) throws IOException { try {/*w w w . j a va 2 s . c o m*/ LMCPointofSalesSystem connect = new LMCPointofSalesSystem(); con = connect.con; st = connect.s; Document document = new Document(PageSize.A4.rotate(), 0, 0, 0, 0); PdfWriter.getInstance(document, new FileOutputStream(tblName + ".pdf")); document.open(); Image image = Image.getInstance("src/lmcpointofsalessystem/Assets/header3.png"); document.add(image); document.setMarginMirroring(true); PdfPTable newheaderTable; newheaderTable = getDatas(tblName); newheaderTable.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(newheaderTable); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(PDFCustomers.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(PDFCustomers.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:lmcpointofsalessystem.PDFCustomersEmployee.java
public PDFCustomersEmployee(String tblName) throws IOException { try {/* w w w .ja v a 2 s . co m*/ LMCPointofSalesSystem connect = new LMCPointofSalesSystem(); con = connect.con; st = connect.s; Document document = new Document(PageSize.A4.rotate(), 0, 0, 0, 0); PdfWriter.getInstance(document, new FileOutputStream(tblName + ".pdf")); document.open(); Image image = Image.getInstance("src/lmcpointofsalessystem/Assets/header3.png"); document.add(image); document.setMarginMirroring(true); PdfPTable newheaderTable; newheaderTable = getDatas(tblName); newheaderTable.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(newheaderTable); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(PDFCustomersEmployee.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(PDFCustomersEmployee.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:lmcpointofsalessystem.PDFOrders.java
public PDFOrders(String tblName) throws IOException { try {//from w ww. j a v a 2 s . c om LMCPointofSalesSystem connect = new LMCPointofSalesSystem(); con = connect.con; st = connect.s; Document document = new Document(PageSize.A4.rotate(), 0, 0, 0, 0); PdfWriter.getInstance(document, new FileOutputStream(tblName + ".pdf")); document.open(); Image image = Image.getInstance("src/lmcpointofsalessystem/Assets/header3.png"); document.add(image); document.setMarginMirroring(true); PdfPTable newheaderTable; newheaderTable = getDatas(tblName); newheaderTable.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(newheaderTable); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(PDFEmployees.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(PDFEmployees.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
public byte[] writePage() throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try {//w w w . ja va2 s . c om logo = Image.getInstance(root.getAbsolutePath() + "/logo.gif"); logo.setAlignment(Image.ALIGN_LEFT); } catch (Exception exc) { exc.printStackTrace(); } baseArial = BaseFont.createFont(root.getAbsolutePath() + "/objects/arial.ttf", BaseFont.CP1257, BaseFont.EMBEDDED); Document doc = new Document(PageSize.A4, 56.5354331f, 22.6771654f, 28.3464567f, 25.0f); PdfWriter.getInstance(doc, bout); doc.open(); logo.setAbsolutePosition(28.3464567f, doc.getPageSize().height() - logo.height() - 25.0f); doc.add(logo); Paragraph pg = new Paragraph(sdf.format(new Date()), new Font(baseArial, 10)); pg.setAlignment(Element.ALIGN_RIGHT); doc.add(pg); doc.add(new Phrase("\n\n\n")); writeClientInfo(doc); writeTicketInfo(doc); writeJobInfo(doc); writeWorkerInfo(doc); doc.close(); return bout.toByteArray(); }