List of usage examples for com.itextpdf.text Document addSubject
public boolean addSubject(String subject)
From source file:co.unicauca.proyectobase.entidades.MetodosPDF.java
public void createPdf(String filename) throws IOException, DocumentException { // step 1: Crear el objeto Document document = new Document(); // step 2: instanciar para escritura con el objeto creado PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3: agregar los metadatos document.addTitle("Hello World example"); document.addAuthor("Bruno Lowagie"); document.addSubject("This example shows how to add metadata"); document.addKeywords("Metadata, iText, PDF"); document.addCreator("My program using iText"); document.open();/*from ww w . j a va 2s .c o m*/ // step 4: agregar el conteido, en este caso "Parrafo 1" document.add(new Paragraph("Parrafo 1")); // step 5: cerrar el archivo que se creo document.close(); }
From source file:com.ainfosec.macresponse.report.PdfGenerator.java
License:Open Source License
private static void addMetaData(String caseName, String authorName, Document document) { document.addTitle(caseName);//from ww w . ja va 2s . c o m document.addSubject("MacResponse Console"); document.addKeywords(""); document.addAuthor(authorName); document.addCreator(System.getProperty("user.name")); }
From source file:com.algoboss.erp.util.report.PDFExporter.java
License:Apache License
public void export(FacesContext context, DataTable table, String filename, String encodingType) throws IOException { try {//from w w w. j av a 2 s .com Document document = new Document(PageSize.A4, 25f, 25f, 25f, 25f); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); if (!document.isOpen()) { document.open(); } document.addAuthor("Algo Boss"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle(filename); //document.setMargins(1f, 1f, 1f, 1f); //document.setPageSize(PageSize.A4); document.add(exportPDFTable(context, table, false, false, false, encodingType)); //document.setMargins(1f, 1f, 1f, 1f); //document.setPageSize(PageSize.A4); document.close(); //writePDFToResponse(context.getExternalContext(), baos, filename); writePDFToResponseNew(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:com.algoboss.erp.util.report.PDFExporter2.java
License:Apache License
public void export(FacesContext context, DataTable table, String filename) throws IOException { try {//from ww w . j av a2s . c om Document document = new Document(PageSize.A4); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(1000000); FileOutputStream file = new FileOutputStream("D://Documents//testeLink.pdf"); PdfWriter pdfWriter = PdfWriter.getInstance(document, file); document.open(); document.addAuthor("Algo Boss"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle("Please read this"); //XMLWorkerHelper worker = XMLWorkerHelper.getInstance(); DataTableRenderer render = new DataTableRenderer(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.reset(); ExternalContext externalContext = context.getExternalContext(); //BufferedWriter writer = new BufferedWriter(baos2,true); OutputStreamWriter writer = new OutputStreamWriter(baos2, "iso-8859-1"); context.setResponseWriter(context.getRenderKit().createResponseWriter(writer, null, "iso-8859-1")); render.encodeEnd(context, table); //System.out.println(new String(baos2.toByteArray(), "utf-8")); /*writer.write( "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\">\n" + "<title>Plataforma de Gerenciamento</title>");*/ /* externalContext.setResponseHeader("Expires", "0"); externalContext.setResponseHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); externalContext.setResponseHeader("Pragma", "public"); externalContext.setResponseHeader("Content-disposition", "inline;filename=" + filename + ".pdf"); externalContext.setResponseContentType("application/pdf"); externalContext.setResponseContentLength(baos.size()); externalContext.addResponseCookie(Constants.DOWNLOAD_COOKIE, "true", new HashMap<String, Object>()); OutputStream out = externalContext.getResponseOutputStream(); baos.writeTo(out); externalContext.responseFlushBuffer(); */ response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline;filename=\"" + filename + "\";"); //String str = "<html><head></head><body>" + new String(baos2.toByteArray()) + "</body></html>"; String str = "<html><head></head><body>" + "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\"/>\n" + "<title>Plataforma de Gerenciamento</title>" + "<div id='tabView:ad_j_id77' class='ui-datatable ui-widget ui-algo-element ui-algo-element-container data-list'><div class='ui-datatable-header ui-widget-header ui-corner-top'><div id='tabView:ad_j_id77:ad_j_id41' class='ui-panel ui-widget ui-widget-content ui-corner-all ui-algo-element ui-algo-element-container'><div id='tabView:ad_j_id77:ad_j_id41_content' class='ui-panel-content ui-widget-content'><label id='tabView:ad_j_id77:ad_j_id39' class='ui-outputlabel ui-algo-element ui-algo-element-value'>Listagem: FUNCION?RIO</label><label id='tabView:ad_j_id77:ad_j_id40' class='ui-outputlabel ui-algo-element ui-algo-element-value' style='float:right;top:-5px;position: relative;'>Pesquisar: <input id='tabView:ad_j_id77:globalFilter' name='tabView:ad_j_id77:globalFilter' type='text' value='' onkeyup='funcionarioDataTable.filter()' class='ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all ui-algo-element ui-algo-element-value' /><script id='tabView:ad_j_id77:globalFilter_s' type='text/javascript'>PrimeFaces.cw('InputText','widget_tabView_ad_j_id77_globalFilter',{id:'tabView:ad_j_id77:globalFilter'});</script></label></div></div><script id='tabView:ad_j_id77:ad_j_id41_s' type='text/javascript'>PrimeFaces.cw('Panel','widget_tabView_ad_j_id77_ad_j_id41',{id:'tabView:ad_j_id77:ad_j_id41'});</script></div><div id='tabView:ad_j_id77_paginator_top' class='ui-paginator ui-paginator-top ui-widget-header'><span class='ui-paginator-first ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-first'>p</span></span><span class='ui-paginator-prev ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-prev'>p</span></span><span class='ui-paginator-pages'><span class='ui-paginator-page ui-state-default ui-state-active ui-corner-all'>1</span><span class='ui-paginator-page ui-state-default ui-corner-all'>2</span></span><span class='ui-paginator-next ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-next'>p</span></span><span class='ui-paginator-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-end'>p</span></span></div><div class='ui-datatable-tablewrapper'><table role='grid'><thead id='tabView:ad_j_id77_head'><tr role='row'><th id='tabView:ad_j_id77:ad_j_id44' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span>Nome</span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id44:filter' name='tabView:ad_j_id77:ad_j_id44:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id48' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id45'>Usurio</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id48:filter' name='tabView:ad_j_id77:ad_j_id48:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id52' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id49'>Admisso</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id52:filter' name='tabView:ad_j_id77:ad_j_id52:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id56' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader' style='text-align:center;'><span><span id='tabView:ad_j_id77:ad_j_id53'>Afastado</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id56:filter' name='tabView:ad_j_id77:ad_j_id56:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id60' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id57'>Veculo</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id60:filter' name='tabView:ad_j_id77:ad_j_id60:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id64' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id61'>MATR?CULA</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id64:filter' name='tabView:ad_j_id77:ad_j_id64:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id68' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id65'>CPF</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id68:filter' name='tabView:ad_j_id77:ad_j_id68:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id72' class='ui-state-default' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id69'>SAL?RIO</span></span></th><th id='tabView:ad_j_id77:ad_j_id76' class='ui-state-default' role='columnheader' style='text-align:center;'><span>Ao</span></th></tr></thead><tfoot></tfoot><tbody id='tabView:ad_j_id77_data' class='ui-datatable-data ui-widget-content'><tr data-ri='0' data-rk='315' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id42'>MARCUS2</span><a id='tabView:ad_j_id77:0:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id46'>SDASA2</span><a id='tabView:ad_j_id77:0:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id50'>2013/08/15</span><a id='tabView:ad_j_id77:0:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:0:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:0:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:0:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id62'>123124</span><a id='tabView:ad_j_id77:0:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id66'></span><a id='tabView:ad_j_id77:0:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id70'></span><a id='tabView:ad_j_id77:0:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:0:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:0:ad_j_id74'> | </span><a id='tabView:ad_j_id77:0:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='1' data-rk='318' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id42'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id46'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id50'>2013/08/07</span><a id='tabView:ad_j_id77:1:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:1:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:1:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id58'></span><a id='tabView:ad_j_id77:1:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id62'></span><a id='tabView:ad_j_id77:1:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id66'></span><a id='tabView:ad_j_id77:1:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id70'></span><a id='tabView:ad_j_id77:1:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:1:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:1:ad_j_id74'> | </span><a id='tabView:ad_j_id77:1:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='2' data-rk='319' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id42'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id46'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id50'></span><a id='tabView:ad_j_id77:2:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:2:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:2:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id58'>BMW - BMW-9999</span><a id='tabView:ad_j_id77:2:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id62'>TESTE123123</span><a id='tabView:ad_j_id77:2:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:2:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id70'>12.345,67</span><a id='tabView:ad_j_id77:2:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:2:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:2:ad_j_id74'> | </span><a id='tabView:ad_j_id77:2:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='3' data-rk='320' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id42'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id46'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id50'>2013/08/22</span><a id='tabView:ad_j_id77:3:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:3:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:3:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:3:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id62'></span><a id='tabView:ad_j_id77:3:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id66'></span><a id='tabView:ad_j_id77:3:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id70'></span><a id='tabView:ad_j_id77:3:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:3:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:3:ad_j_id74'> | </span><a id='tabView:ad_j_id77:3:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='4' data-rk='321' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id42'>CLEIDE2</span><a id='tabView:ad_j_id77:4:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id46'>CLEIDE DA SILVA</span><a id='tabView:ad_j_id77:4:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id50'>2013/08/19</span><a id='tabView:ad_j_id77:4:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:4:ad_j_id54' class=' ui-icon ui-icon-check ' style='display:inline-block;'>true</span><a id='tabView:ad_j_id77:4:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id58'>EEQEWEQE - QWEQ</span><a id='tabView:ad_j_id77:4:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id62'></span><a id='tabView:ad_j_id77:4:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:4:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id70'>456,70</span><a id='tabView:ad_j_id77:4:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:4:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:4:ad_j_id74'> | </span><a id='tabView:ad_j_id77:4:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='5' data-rk='322' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id42'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id46'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id50'>2013/08/20</span><a id='tabView:ad_j_id77:5:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:5:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:5:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id58'></span><a id='tabView:ad_j_id77:5:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id62'></span><a id='tabView:ad_j_id77:5:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id66'></span><a id='tabView:ad_j_id77:5:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id70'></span><a id='tabView:ad_j_id77:5:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:5:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:5:ad_j_id74'> | </span><a id='tabView:ad_j_id77:5:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr>" + "</tbody></table></div></div>" + "</body></html>"; //worker.parseXHtml(pdfWriter, document, new StringReader(str)); response.setContentLength(baos.size()); response.getOutputStream().write(baos.toByteArray(), 0, baos.size()); //System.out.println(str); document.close(); pdfWriter.close(); baos.close(); baos2.close(); file.close(); FacesContext.getCurrentInstance().responseComplete(); //writePDFToResponse(context.getExternalContext(), baos, filename); //writePDFToResponseNew(context.getExternalContext(), baos, filename); } catch (IOException e) { throw new IOException(e.getMessage()); } catch (Exception ex) { Logger.getLogger(PDFExporter2.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.algoboss.erp.util.report.PDFExporter2.java
License:Apache License
public void export2(FacesContext context, String htmltable, String filename) throws IOException { try {/*from w w w.j a v a 2 s .co m*/ Document document = new Document(PageSize.A4); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(1000000); FileOutputStream file = new FileOutputStream("D://Documents//testeLink.pdf"); PdfWriter pdfWriter = PdfWriter.getInstance(document, file); document.open(); document.addAuthor("Algo Boss"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle("Please read this"); XMLWorkerHelper worker = XMLWorkerHelper.getInstance(); DataTableRenderer render = new DataTableRenderer(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.reset(); ExternalContext externalContext = context.getExternalContext(); //BufferedWriter writer = new BufferedWriter(baos2,true); OutputStreamWriter writer = new OutputStreamWriter(baos2, "iso-8859-1"); context.setResponseWriter(context.getRenderKit().createResponseWriter(writer, null, "iso-8859-1")); //render.encodeEnd(context, table); //System.out.println(new String(baos2.toByteArray(), "utf-8")); /*writer.write( "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\">\n" + "<title>Plataforma de Gerenciamento</title>");*/ /* externalContext.setResponseHeader("Expires", "0"); externalContext.setResponseHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); externalContext.setResponseHeader("Pragma", "public"); externalContext.setResponseHeader("Content-disposition", "inline;filename=" + filename + ".pdf"); externalContext.setResponseContentType("application/pdf"); externalContext.setResponseContentLength(baos.size()); externalContext.addResponseCookie(Constants.DOWNLOAD_COOKIE, "true", new HashMap<String, Object>()); OutputStream out = externalContext.getResponseOutputStream(); baos.writeTo(out); externalContext.responseFlushBuffer(); */ response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline;filename=\"" + filename + "\";"); //String str = "<html><head></head><body>" + new String(baos2.toByteArray()) + "</body></html>"; String str = "<html><head></head><body>" + "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\"/>\n" + "<title>Plataforma de Gerenciamento</title>" + "<div id='tabView:ad_j_id77' class='ui-datatable ui-widget ui-algo-element ui-algo-element-container data-list'><div class='ui-datatable-header ui-widget-header ui-corner-top'><div id='tabView:ad_j_id77:ad_j_id41' class='ui-panel ui-widget ui-widget-content ui-corner-all ui-algo-element ui-algo-element-container'><div id='tabView:ad_j_id77:ad_j_id41_content' class='ui-panel-content ui-widget-content'><label id='tabView:ad_j_id77:ad_j_id39' class='ui-outputlabel ui-algo-element ui-algo-element-value'>Listagem: FUNCION?RIO</label><label id='tabView:ad_j_id77:ad_j_id40' class='ui-outputlabel ui-algo-element ui-algo-element-value' style='float:right;top:-5px;position: relative;'>Pesquisar: <input id='tabView:ad_j_id77:globalFilter' name='tabView:ad_j_id77:globalFilter' type='text' value='' onkeyup='funcionarioDataTable.filter()' class='ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all ui-algo-element ui-algo-element-value' /><script id='tabView:ad_j_id77:globalFilter_s' type='text/javascript'>PrimeFaces.cw('InputText','widget_tabView_ad_j_id77_globalFilter',{id:'tabView:ad_j_id77:globalFilter'});</script></label></div></div><script id='tabView:ad_j_id77:ad_j_id41_s' type='text/javascript'>PrimeFaces.cw('Panel','widget_tabView_ad_j_id77_ad_j_id41',{id:'tabView:ad_j_id77:ad_j_id41'});</script></div><div id='tabView:ad_j_id77_paginator_top' class='ui-paginator ui-paginator-top ui-widget-header'><span class='ui-paginator-first ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-first'>p</span></span><span class='ui-paginator-prev ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-prev'>p</span></span><span class='ui-paginator-pages'><span class='ui-paginator-page ui-state-default ui-state-active ui-corner-all'>1</span><span class='ui-paginator-page ui-state-default ui-corner-all'>2</span></span><span class='ui-paginator-next ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-next'>p</span></span><span class='ui-paginator-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-end'>p</span></span></div><div class='ui-datatable-tablewrapper'><table role='grid'><thead id='tabView:ad_j_id77_head'><tr role='row'><th id='tabView:ad_j_id77:ad_j_id44' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span>Nome</span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id44:filter' name='tabView:ad_j_id77:ad_j_id44:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id48' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id45'>Usurio</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id48:filter' name='tabView:ad_j_id77:ad_j_id48:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id52' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id49'>Admisso</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id52:filter' name='tabView:ad_j_id77:ad_j_id52:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id56' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader' style='text-align:center;'><span><span id='tabView:ad_j_id77:ad_j_id53'>Afastado</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id56:filter' name='tabView:ad_j_id77:ad_j_id56:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id60' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id57'>Veculo</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id60:filter' name='tabView:ad_j_id77:ad_j_id60:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id64' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id61'>MATR?CULA</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id64:filter' name='tabView:ad_j_id77:ad_j_id64:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id68' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id65'>CPF</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id68:filter' name='tabView:ad_j_id77:ad_j_id68:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id72' class='ui-state-default' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id69'>SAL?RIO</span></span></th><th id='tabView:ad_j_id77:ad_j_id76' class='ui-state-default' role='columnheader' style='text-align:center;'><span>Ao</span></th></tr></thead><tfoot></tfoot><tbody id='tabView:ad_j_id77_data' class='ui-datatable-data ui-widget-content'><tr data-ri='0' data-rk='315' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id42'>MARCUS2</span><a id='tabView:ad_j_id77:0:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id46'>SDASA2</span><a id='tabView:ad_j_id77:0:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id50'>2013/08/15</span><a id='tabView:ad_j_id77:0:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:0:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:0:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:0:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id62'>123124</span><a id='tabView:ad_j_id77:0:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id66'></span><a id='tabView:ad_j_id77:0:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id70'></span><a id='tabView:ad_j_id77:0:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:0:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:0:ad_j_id74'> | </span><a id='tabView:ad_j_id77:0:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='1' data-rk='318' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id42'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id46'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id50'>2013/08/07</span><a id='tabView:ad_j_id77:1:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:1:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:1:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id58'></span><a id='tabView:ad_j_id77:1:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id62'></span><a id='tabView:ad_j_id77:1:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id66'></span><a id='tabView:ad_j_id77:1:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id70'></span><a id='tabView:ad_j_id77:1:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:1:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:1:ad_j_id74'> | </span><a id='tabView:ad_j_id77:1:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='2' data-rk='319' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id42'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id46'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id50'></span><a id='tabView:ad_j_id77:2:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:2:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:2:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id58'>BMW - BMW-9999</span><a id='tabView:ad_j_id77:2:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id62'>TESTE123123</span><a id='tabView:ad_j_id77:2:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:2:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id70'>12.345,67</span><a id='tabView:ad_j_id77:2:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:2:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:2:ad_j_id74'> | </span><a id='tabView:ad_j_id77:2:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='3' data-rk='320' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id42'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id46'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id50'>2013/08/22</span><a id='tabView:ad_j_id77:3:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:3:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:3:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:3:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id62'></span><a id='tabView:ad_j_id77:3:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id66'></span><a id='tabView:ad_j_id77:3:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id70'></span><a id='tabView:ad_j_id77:3:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:3:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:3:ad_j_id74'> | </span><a id='tabView:ad_j_id77:3:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='4' data-rk='321' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id42'>CLEIDE2</span><a id='tabView:ad_j_id77:4:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id46'>CLEIDE DA SILVA</span><a id='tabView:ad_j_id77:4:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id50'>2013/08/19</span><a id='tabView:ad_j_id77:4:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:4:ad_j_id54' class=' ui-icon ui-icon-check ' style='display:inline-block;'>true</span><a id='tabView:ad_j_id77:4:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id58'>EEQEWEQE - QWEQ</span><a id='tabView:ad_j_id77:4:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id62'></span><a id='tabView:ad_j_id77:4:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:4:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id70'>456,70</span><a id='tabView:ad_j_id77:4:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:4:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:4:ad_j_id74'> | </span><a id='tabView:ad_j_id77:4:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='5' data-rk='322' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id42'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id46'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id50'>2013/08/20</span><a id='tabView:ad_j_id77:5:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:5:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:5:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id58'></span><a id='tabView:ad_j_id77:5:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id62'></span><a id='tabView:ad_j_id77:5:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id66'></span><a id='tabView:ad_j_id77:5:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id70'></span><a id='tabView:ad_j_id77:5:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:5:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:5:ad_j_id74'> | </span><a id='tabView:ad_j_id77:5:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr>" + "</tbody></table></div></div>" + "</body></html>"; ElementHandler eh = new ElementHandler() { public List<Writable> elements = new ArrayList<Writable>(); @Override public void add(Writable wrtbl) { if (wrtbl instanceof WritableElement) { elements.add(wrtbl); } //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; //worker.parseXHtml(eh, new StringReader(htmltable)); worker.parseXHtml(pdfWriter, document, new StringReader(htmltable)); response.setContentLength(baos.size()); response.getOutputStream().write(baos.toByteArray(), 0, baos.size()); //System.out.println(str); document.close(); pdfWriter.close(); baos.close(); baos2.close(); file.close(); FacesContext.getCurrentInstance().responseComplete(); //writePDFToResponse(context.getExternalContext(), baos, filename); //writePDFToResponseNew(context.getExternalContext(), baos, filename); } catch (IOException e) { throw new IOException(e.getMessage()); } catch (Exception ex) { Logger.getLogger(PDFExporter2.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.alokomkar.aliensonearth.report.AbstractPdfReport.java
/** * virtual method to add meta data for the page * @param document Document where meta data need to be added. *//*from ww w.j a va 2 s.c o m*/ public void addPageMetaData(Document document) { String title = getPageTitle(); String subjct = getPageSubject(); if (title != null) document.addTitle(title); if (subjct != null) document.addSubject(subjct); document.addAuthor(ProjectMessages.REPORT_GENERATOR); document.addCreator(ProjectMessages.REPORT_CREATOR); document.addCreationDate(); addLineSeperator(document); }
From source file:com.auskeny.ems.print.PdfCreator.java
public static void addMetaData(Document document) { document.addTitle("My first PDF"); document.addSubject("Using iText"); document.addKeywords("Java, PDF, iText"); document.addAuthor("Lars Vogel"); document.addCreator("Lars Vogel"); }
From source file:com.coast.PDFPrinter_iText.java
License:Apache License
/** * Prints the document at its actual size. This is the recommended way to print. *//*w w w .j ava 2 s . c o m*/ private static void print(String pFileName, String pPayload) throws IOException, Exception { Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(pFileName)); // step 3 document.open(); // step 4 String _dateTime = LocalDateTime.now().toString(); document.addTitle("List of All Customers & their assets as of: " + _dateTime); document.addCreationDate(); document.addSubject("List of All Customers & their assets as of: " + _dateTime); Font _font = new Font(); _font.setColor(BaseColor.BLUE); _font.setStyle(Font.BOLD); _font.setSize(15); Chunk _chunk = new Chunk("List of All Customers & their assets as of: " + _dateTime); _chunk.setFont(_font); Paragraph _header = new Paragraph(); _header.add(_chunk); document.add(_header); document.add(new Paragraph(pPayload)); // step 5 document.close(); }
From source file:com.debashubham.dumpy.ChainageCalcActivity.java
private void addMetaData(Document document) { document.addTitle("Report generated on:" + formattedDate); document.addSubject("Dumpy Level Report"); document.addKeywords("Dumpy Level, PDF"); document.addAuthor("Dumpy"); document.addCreator("Dumpy"); }
From source file:com.dexter.fms.mbean.ReportsMBean.java
@SuppressWarnings("unchecked") public void createPDF(int type, String filename, int pageType) { try {/*from w w w . j a v a2 s .c o m*/ FacesContext context = FacesContext.getCurrentInstance(); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new HeaderFooter()); writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788)); if (!document.isOpen()) { document.open(); } switch (pageType) { case 1: document.setPageSize(PageSize.A4); break; case 2: document.setPageSize(PageSize.A4.rotate()); break; } document.addAuthor("FMS"); document.addCreationDate(); document.addCreator("FMS"); document.addSubject("Report"); document.addTitle(getReport_title()); PdfPTable headerTable = new PdfPTable(1); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "satraklogo.jpg"; Hashtable<String, Object> params = new Hashtable<String, Object>(); params.put("partner", dashBean.getUser().getPartner()); GeneralDAO gDAO = new GeneralDAO(); Object pSettingsObj = gDAO.search("PartnerSetting", params); PartnerSetting setting = null; if (pSettingsObj != null) { Vector<PartnerSetting> pSettingsList = (Vector<PartnerSetting>) pSettingsObj; for (PartnerSetting e : pSettingsList) { setting = e; } } gDAO.destroy(); PdfPCell c = null; if (setting != null && setting.getLogo() != null) { Image logoImg = Image.getInstance(setting.getLogo()); logoImg.scaleToFit(212, 51); c = new PdfPCell(logoImg); } else c = new PdfPCell(Image.getInstance(logo)); c.setBorder(0); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); Paragraph stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { //font exception } Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph(getReport_title(), font)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); if (getReport_start_dt() != null && getReport_end_dt() != null) { stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(10); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); new Font(helvetica, 12, Font.NORMAL); Paragraph ch = new Paragraph("From " + getReport_start_dt() + " to " + getReport_end_dt(), font); c = new PdfPCell(ch); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); } stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); document.add(headerTable); PdfPTable pdfTable = exportPDFTable(type); if (pdfTable != null) document.add(pdfTable); //Keep modifying your pdf file (add pages and more) document.close(); String fileName = filename + ".pdf"; writeFileToResponse(context.getExternalContext(), baos, fileName, "application/pdf"); context.responseComplete(); } catch (Exception e) { e.printStackTrace(); } }