public ActionResult Index(SvgConvertModel model) { if (ModelState.IsValid) { var svgDataList = CommonHelper.GetRequestBytes(this, NUMBER_OF_FILES, "ImageData", "image/svg"); var bitmap = SvgToBitmap(svgDataList, model.Width, model.Height); if (bitmap != null) { if (model.Format == FormatType.PNG) { var bitmapStream = new MemoryStream(); bitmap.Save(bitmapStream, ImageFormat.Png); bitmapStream.Position = 0; return(File(bitmapStream, "image/x-png", string.Format("{0}-{1}.png", Guid.NewGuid(), DateTime.Now.ToShortDateString()))); } else if (model.Format == FormatType.PDF) { var pdfBytes = GetPdfStream(bitmap); return(File(pdfBytes, "application/pdf", string.Format("{0}-{1}.pdf", Guid.NewGuid(), DateTime.Now.ToShortDateString()))); } } } model.NumberOfFiles = NUMBER_OF_FILES; return(View(model)); }
public ActionResult Index() { var model = new SvgConvertModel() { Format = FormatType.PNG, NumberOfFiles = NUMBER_OF_FILES, Height = BASE_HEIGHT, Width = BASE_WIDTH }; return(View(model)); }