if (transformto != null && transformto.equals(TO_PDF)) {
try {
if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PDFTranscoder t = new PDFTranscoder();
TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
TranscoderOutput output = new TranscoderOutput(bout);
t.transcode(input, output);
resp.setCharacterEncoding("UTF-8");
resp.setContentType("text/plain");
resp.getWriter().write("<object data=\"data:application/pdf;base64," + Base64.encodeBase64(bout.toByteArray()) + "\" type=\"application/pdf\"></object>");
} else {
storeInRepository(uuid, rawSvg, transformto, processid, repository);
resp.setContentType("application/pdf");
if (processid != null) {
resp.setHeader("Content-Disposition",
"attachment; filename=\"" + processid + ".pdf\"");
} else {
resp.setHeader("Content-Disposition",
"attachment; filename=\"" + uuid + ".pdf\"");
}
PDFTranscoder t = new PDFTranscoder();
TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
TranscoderOutput output = new TranscoderOutput(resp.getOutputStream());
t.transcode(input, output);
}
} catch (TranscoderException e) {
resp.sendError(500, e.getMessage());
}
} else if (transformto != null && transformto.equals(TO_PNG)) {
try {
if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
TranscoderOutput output = new TranscoderOutput(bout);
t.transcode(input, output);
resp.setCharacterEncoding("UTF-8");
resp.setContentType("text/plain");
resp.getWriter().write("<img src=\"data:image/png;base64," + Base64.encodeBase64(bout.toByteArray()) + "\">");
} else {
storeInRepository(uuid, rawSvg, transformto, processid, repository);
resp.setContentType("image/png");
if (processid != null) {
resp.setHeader("Content-Disposition", "attachment; filename=\"" + processid + ".png\"");
} else {
resp.setHeader("Content-Disposition", "attachment; filename=\"" + uuid + ".png\"");
}
PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
TranscoderInput input = new TranscoderInput(new StringReader(
formattedSvg));
TranscoderOutput output = new TranscoderOutput(
resp.getOutputStream());
t.transcode(input, output);
}
} catch (TranscoderException e) {
resp.sendError(500, e.getMessage());
}
} else if (transformto != null && transformto.equals(TO_SVG)) {