svg-to-otherformat 及文件输出

//获取请求参数并创建svg文件
FileUtils.writeStringToFile(new File("c://pp//barChart.svg"), request.getParameter("svg"),"utf-8");
//转换文件 svg-to-pdf
SVGConverter c = new SVGConverter();
c.setSources(new String[]{"c://pp//barChart.svg"});
c.setDst(new java.io.File("c://pp//test-reports"));
c.setDestinationType(DestinationType.PDF);
c.execute();
//设置响应报头为pdf格式
response.setHeader("Location", "barChart.pdf");
response.setHeader("Content-Disposition", "attachment; filename=" + "barChart.pdf");
response.setContentType("application/pdf");
//输出文件
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(new java.io.File("c://pp//test-reports//barChart.pdf"));
PrintWriter writer = response.getWriter();
int i;
while((i = fileInputStream.read()) != -1)
{
writer.write(i);
}
writer.flush();

你可能感兴趣的:(jsp)