我还没有找到一个如何使用JasperReports打印PDF文件的好例子。是否可以在不创建报告的情况下打印PDF?我需要JasperReports的打印功能,因为Java API for Printing PDF不起作用。
我的代码:
...
@Path("report")
@GET
@UnitOfWork
@Produces({"application/pdf"})
public Response createRaportList(@Context HttpServletResponse response,
@Auth Credentials credentials, @Context UriInfo allUri) throws IOException, DRException {
LOGGER.info("requestIssue başarı ile oluşturuldu");
final Credentials cri=credentials;
final OutputStream stream = response.getOutputStream();
final List<String> lstFile=allUri.getQueryParameters().get("orderBy");
new Thread(new Runnable() {
@Override
public synchronized void run() {
for (String fileOid:lstFile){
createReportForFileOid(stream,cri,Long.parseLong(fileOid));
}
}
}).run();
return createReportForFileOid(stream,credentials,Long.parseLong(lstFile.get(0)));
}
createReportForFileOid方法返回Response,即处理create jasper和pdf