Olá para todos!
Sou novo em programação e estou com um problema ao gerar um relatório em pdf.
O método não gera o relatório e me da essa advertência no log.
mai 12, 2019 5:24:14 PM net.sf.jasperreports.engine.export.PdfGlyphRenderer determinePatchedItext
ADVERTÊNCIA: Unpatched iText found, cannot use glyph rendering
public void geraEtiquetaPdf(Long id) throws SQLException, Exception {
addAtributoSessao(“idAgenda”, id);
agendamento.setId(id);
Connection con = null;
ServletOutputStream outputStream = null;
InputStream report = null;
// acha jrxml dentro da aplicação
String pathSeparator = System.getProperty(“file.separator”) ;
String pathRaiz = getServletContext().getRealPath(pathSeparator+“relatorios”+pathSeparator+“etiqueta”);
String pathRelatorio = pathRaiz+pathSeparator+“etiqueta.jasper”;
// abre conexão com o banco
try {
con = conexao.gatConnection();
// prepara parâmetros
Map<String, Object> parametros = new HashMap<>();
parametros.put(“codigo”, agendamento.getId());
report = new FileInputStream(new File(pathRelatorio));
JasperPrint print = JasperFillManager.fillReport(report, parametros, con);
byte[] bytes = getBytes(print);
HttpServletResponse response = getResponse();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; etiqueta.pdf");
response.setContentLength(bytes.length);
outputStream = response.getOutputStream();
outputStream.write(bytes, 0, bytes.length);
outputStream.flush();
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception e) {
logg.error("Erro ao gerar o relatório de horas trabalhadas", e);
throw new Exception();
}
finally {
try {
if(outputStream != null) {
outputStream.close();
}
if(report != null) {
report.close();
}
} catch (Exception e) {
logg.error("Erro ao fechar o outputStream/report", e);
}
try {
if(con != null){
con.close();
con = null;
}
} catch (Exception e) {
logg.error("Error ao fechar a Conexão", e);
}
}
}
private byte[] getBytes(JasperPrint print) throws Exception {
byte[] bytes = null;
ByteArrayOutputStream byteArrayOutputStream = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
JRExporter exporterPDF = new JRPdfExporter();
exporterPDF.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
exporterPDF.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, byteArrayOutputStream);
exporterPDF.exportReport();
bytes = byteArrayOutputStream.toByteArray();
byteArrayOutputStream.close();
} catch (Exception e) {
logg.error("Erro ao gerar os bytes", e);
throw new Exception(e);
}
finally {
if(byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
}
return bytes;
}
na minha pagina eu chamo e passo um parâmetro no método
<f:param name=“idAgenda” value="#{agenda.id}" />
</a>