log.debug("pBean.getWidth(),pBean.getHeight()"+pBean.getWidth()+","+pBean.getHeight());
// Create an instance of the SVG Generator.
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
svgGenerator = WhiteboardMapToSVG.getInstance().convertMapToSVG(svgGenerator, whiteBoardMap);
// Finally, stream out SVG to the standard output using
// UTF-8 encoding.
boolean useCSS = true; // we want to use CSS style attributes
//Writer out = new OutputStreamWriter(System.out, "UTF-8");
String requestedFile = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+".svg";
if (exportType.equals("svg")) {
//OutputStream out = httpServletResponse.getOutputStream();
//httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
//httpServletResponse.setHeader("Content-Disposition","attachment; filename=\"" + requestedFile + "\"");
Writer out = httpServletResponse.getWriter();
svgGenerator.stream(out, useCSS);
} else if (exportType.equals("png") || exportType.equals("jpg")
|| exportType.equals("gif") || exportType.equals("tif")
|| exportType.equals("pdf")){
String current_dir = getServletContext().getRealPath("/");
String working_dir = current_dir + "uploadtemp" + File.separatorChar;
String requestedFileSVG = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+".svg";
String resultFileName = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+"."+exportType;
log.debug("current_dir: "+current_dir);
log.debug("working_dir: "+working_dir);
log.debug("requestedFileSVG: "+requestedFileSVG);
log.debug("resultFileName: "+resultFileName);
File svgFile = new File(working_dir + requestedFileSVG);
File resultFile = new File(working_dir + resultFileName);
log.debug("svgFile: "+svgFile.getAbsolutePath());
log.debug("resultFile: "+resultFile.getAbsolutePath());
log.debug("svgFile P: "+svgFile.getPath());
log.debug("resultFile P: "+resultFile.getPath());
FileWriter out = new FileWriter(svgFile);
svgGenerator.stream(out, useCSS);
HashMap<String,Object> returnError = GenerateImage.getInstance().convertImageByTypeAndSize(
svgFile.getAbsolutePath(), resultFile.getAbsolutePath(),
pBean.getWidth(), pBean.getHeight());