Block copy PDF document
- by Wiliam Witter
hello Gentlemen, I would like block copy (ctrl+c ctrl+v) PDF document using java. I have a code that build a PDF document with JasperReport...
//seta o caminho dos arquivos jasper
String pathLote = ScopeSupport.getServletContext().getRealPath("priv/sgc/relatorios/AtaPregaoLotePageReport.jasper");
String pathCabecalho = ScopeSupport.getServletContext().getRealPath("priv/sgc/relatorios/CabecalhoPageReport.jasper");
String pathRodape = ScopeSupport.getServletContext().getRealPath("priv/sgc/relatorios/rodapePageReport.jasper");
String imagemDir = ScopeSupport.getServletContext().getRealPath("/priv/comum/img");
//HashMap parametros passa o parametro usado na query e o caminho da imagem
HashMap<String,Object> parametros = new HashMap<String,Object>();
parametros.put("idPregao", idPregao);
parametros.put("idLote", idLote);
parametros.put("IMAGEM_DIR", imagemDir + "/");
parametros.put("USUARIO", "NomeUsuario" );
parametros.put("texto", texto);
parametros.put("numeroAta", numAta);
if(numAta != null && numAta > 0)
parametros.put("relatorio", "Ata "+numAta);
HashMap<String,Object> parametrosSub = new HashMap<String,Object>();
parametrosSub.put("CabecalhoPageReport", pathCabecalho);
parametrosSub.put("rodapePageReport", pathRodape);
parametrosSub.put("AtaPregaoPorLotePageReport", pathLote);
for(String element : parametrosSub.keySet()){
parametros.put(element, (JasperReport) JRLoader.loadObject((String) (parametrosSub.get(element))));
}
JasperReport report = (JasperReport) JRLoader.loadObject( pathLote );
JasperPrint printRel = JasperFillManager.fillReport( report, parametros, getJDBCConnection() );
byte[] bytes = JasperExportManager.exportReportToPdf(printRel);
httpResponse.setHeader("Content-Disposition","attachment; filename=\""+ report.getName() + ".pdf" +"\";");
httpResponse.setContentLength(bytes.length);
httpResponse.setContentType("application/pdf");
ServletOutputStream ouputStream = httpResponse.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
Who can help me with this?