Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            var jsonString = string.Empty;
            var gen        = new PDFGenerator();

            context.Request.InputStream.Position = 0;
            using (var inputStream = new StreamReader(context.Request.InputStream))
            {
                jsonString = inputStream.ReadToEnd();
            }

            var json = JObject.Parse(jsonString);
            var pdf  = gen.CreatePDF(json["json"]["html"].ToString(), json["json"]["cssFilename"].ToString());

            context.Response.Clear();
            context.Response.ClearHeaders();
            context.Response.AddHeader("Content-Disposition", "inline; filename=testclaimpdf.pdf");
            context.Response.AddHeader("Content-Length", pdf.Length.ToString());
            context.Response.ContentType = "application/pdf";
            context.Response.BinaryWrite(pdf);
            context.Response.End();
        }