|
|
|
|
@ -629,7 +629,7 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
System.out.println( "CREATING PDF ..." );
|
|
|
|
|
byte[] pdf = pdfCreator.createPDF( pID, true, withPatrimoniais );
|
|
|
|
|
System.out.println( "\t.. DONE !" );
|
|
|
|
|
showPdf( pdf );
|
|
|
|
|
showPdf( pdf, withPatrimoniais );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
@ -638,40 +638,27 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showPdf( byte[] pdf ) throws Exception
|
|
|
|
|
private void showPdf( byte[] pdf, boolean isPatrimoniais ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
// FacesContext fc = getFacesContext();
|
|
|
|
|
// HttpServletResponse response = (HttpServletResponse) fc.getExternalContext().getResponse();
|
|
|
|
|
// response.setContentType("application/pdf");
|
|
|
|
|
// //response.getOutputStream().flush();
|
|
|
|
|
// response.flushBuffer();
|
|
|
|
|
// response.getOutputStream().write(pdf, 0, pdf.length);
|
|
|
|
|
// fc.getResponseComplete();
|
|
|
|
|
|
|
|
|
|
System.out.println("PDF LEN : " + pdf.length);
|
|
|
|
|
|
|
|
|
|
String filename = isPatrimoniais ? "Plano_Patrimoniais.pdf" : "Plano.pdf";
|
|
|
|
|
System.out.println( "\nPDF LEN : " + pdf.length );
|
|
|
|
|
System.out.println( "FileName : " + filename );
|
|
|
|
|
|
|
|
|
|
FacesContext context = FacesContext.getCurrentInstance();
|
|
|
|
|
HttpServletResponse response =
|
|
|
|
|
( HttpServletResponse ) context.getExternalContext().getResponse();
|
|
|
|
|
HttpServletResponse response = ( HttpServletResponse ) context.getExternalContext().getResponse();
|
|
|
|
|
|
|
|
|
|
response.setHeader( "Expires", "0" );
|
|
|
|
|
response.setHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" );
|
|
|
|
|
//response.setHeader("Content-disposition","inline; filename=kiran.pdf");
|
|
|
|
|
response.setHeader( "Pragma", "public" );
|
|
|
|
|
response.setContentType( "application/pdf" );
|
|
|
|
|
//response.setHeader("Content-Disposition", "attachment;filename=\"ContactList.pdf\"");
|
|
|
|
|
response.addHeader( "Content-disposition", "attachment;filename=\"Plano.pdf\"" );
|
|
|
|
|
|
|
|
|
|
//response.setHeader("Content-disposition", "filename=plano.pdf");
|
|
|
|
|
response.addHeader( "Content-disposition", "attachment;filename=\"" + filename + "\"" );
|
|
|
|
|
response.setContentLength( pdf.length );
|
|
|
|
|
//try {
|
|
|
|
|
response.getOutputStream().write( pdf );
|
|
|
|
|
response.getOutputStream().flush();
|
|
|
|
|
response.getOutputStream().close();
|
|
|
|
|
context.responseComplete();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// ErrorLogger.logException( e );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
response.getOutputStream().write( pdf );
|
|
|
|
|
response.getOutputStream().flush();
|
|
|
|
|
response.getOutputStream().close();
|
|
|
|
|
context.responseComplete();
|
|
|
|
|
|
|
|
|
|
System.out.println( "SHOW PDF done." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|