public void ProcessRequest(HttpContext context) { HttpResponse response = context.Response; response.Clear(); AppState appState = AppState.FromJson(context.Request.Form["state"]); string templateID = context.Request.Form["template"]; string scaleMode = context.Request.Form["scalemode"]; double originalWidth = Convert.ToDouble(context.Request.Form["width"]); // if the user entered a feet-per-inch scale, compute the pixel width of the map // for the scale given the extent width if (scaleMode == "input") { double extentWidth = appState.Extent.Width * (AppContext.AppSettings.MapUnits == "feet" ? 1 : Constants.FeetPerMeter); double scale = Convert.ToDouble(context.Request.Form["scale"]); originalWidth = extentWidth * 96 / scale; scaleMode = "scale"; } PreserveMode preserveMode = (PreserveMode)Enum.Parse(typeof(PreserveMode), scaleMode, true); // read in the user inputs List <String> input = new List <String>(); Configuration.ApplicationRow application = AppContext.GetConfiguration().Application.First(o => o.ApplicationID == appState.Application); Configuration.PrintTemplateRow template = application.GetPrintTemplates().First(o => o.TemplateID == templateID); foreach (Configuration.PrintTemplateContentRow element in template.GetPrintTemplateContentRows().Where(o => o.ContentType == "input")) { string fieldName = String.Format("input_{0}_{1}", template.TemplateID, element.SequenceNo); input.Add(context.Request.Form[fieldName]); } // produce the PDF output PdfMap pdfMap = new PdfMap(appState, templateID, input, preserveMode, originalWidth); pdfMap.Write(response); response.End(); }
public void Initialize(Configuration config, Configuration.ApplicationRow application) { foreach (Configuration.PrintTemplateRow template in application.GetPrintTemplates()) { HtmlGenericControl option = new HtmlGenericControl("option"); option.InnerText = template.TemplateTitle; option.Attributes["value"] = template.TemplateID; ddlPrintTemplate.Controls.Add(option); foreach (Configuration.PrintTemplateContentRow element in template.GetPrintTemplateContentRows().Where(o => o.ContentType == "input")) { HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes["data-templateID"] = template.TemplateID; div.Attributes["class"] = "printInput"; div.Style["width"] = "100%"; div.Style["display"] = "none"; HtmlGenericControl label = new HtmlGenericControl("label"); div.Controls.Add(label); label.InnerText = element.DisplayName; HtmlGenericControl tbo = new HtmlGenericControl("input"); div.Controls.Add(tbo); tbo.Attributes["type"] = "text"; tbo.Attributes["name"] = String.Format("input_{0}_{1}", template.TemplateID, element.SequenceNo); tbo.Attributes["class"] = "Input Text"; pnlPrintInputs.Controls.Add(div); } } foreach (Configuration.ExternalMapRow externalMap in config.ExternalMap) { HtmlGenericControl opt = new HtmlGenericControl("option"); ddlExternalMap.Controls.Add(opt); opt.Attributes["value"] = externalMap.DisplayName; opt.InnerText = externalMap.DisplayName; } }