Exemplo n.º 1
0
 public void GenerateInBatchModeTest()
 {
     _generator.BeginBatch();
     _generator.GeneratePdfFromFile("https://yandex.ru", null, Path.Combine(PDF_DIRECTORY, "yandex.pdf"));
     _generator.GeneratePdfFromFile("https://lenta.ru", null, Path.Combine(PDF_DIRECTORY, "lenta.pdf"));
     _generator.GeneratePdfFromFile("https://meduza.io", null, Path.Combine(PDF_DIRECTORY, "meduza.pdf"));
     _generator.EndBatch();
 }
Exemplo n.º 2
0
        //public ActionResult makeIronPdf()
        //{

        //    HtmlToPdf HtmlToPdf = new IronPdf.HtmlToPdf();
        //    HtmlToPdf.PrintOptions.FitToPaperWidth = true;
        //    HtmlToPdf.PrintOptions.EnableJavaScript = true;
        //    HtmlToPdf.PrintOptions.RenderDelay = 5500;
        //    HtmlToPdf.PrintOptions.MarginBottom = 0;
        //    HtmlToPdf.PrintOptions.MarginLeft = 0;
        //    HtmlToPdf.PrintOptions.MarginRight = 0;
        //    HtmlToPdf.PrintOptions.MarginTop = 0;
        //    PdfResource PDF = HtmlToPdf.RenderUrlAsPdf(new Uri("http://*****:*****@"C:\Users\yousu\Desktop\File.Pdf");
        //    return Content("Done");
        //}



        public string makePDF(int Id)
        {
            string fileName  = Guid.NewGuid().ToString();
            Issue  issue     = db.Issues.Find(Id);
            string path      = Server.MapPath("~/Uploads/" + issue.Folder + "/" + fileName);
            var    htmlToPdf = new HtmlToPdfConverter();

            htmlToPdf.Margins = new PageMargins {
                Top = 0, Bottom = 0, Left = 0, Right = 0
            };
            htmlToPdf.CustomWkHtmlArgs = "--encoding UTF-8 --javascript-delay 5500";
            htmlToPdf.Size             = PageSize.A4;

            //htmlToPdf.CustomWkHtmlArgs = "  --print-media-type ";
            //string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
            //Console.WriteLine(baseUrl);
            string url = "http://" + "localhost/fyp" + "/Article/GetPartialViewByIssueIdForPdf/" + Id;

            htmlToPdf.GeneratePdfFromFile(url, null, path + ".Pdf");

            issue.fileName        = fileName + ".PDF";
            issue.pdfStatus       = 1;
            db.Entry(issue).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(fileName);
        }
        public void GenerateFileByStringAndCover()
        {
            const string fileName = "GenerateFileByStringAndCover.pdf";

            HtmlToPdfConverter generator = new HtmlToPdfConverter();

            generator.GeneratePdfFromFile(HTML_FILE, HTML_CONTENT_COVER, Path.Combine(PDF_DIRECTORY, fileName));
        }
        public void CustomArgsTest()
        {
            const string fileName = "CustomsArgs.pdf";

            HtmlToPdfConverter generator = new HtmlToPdfConverter();

            generator.CustomWkHtmlArgs = " -g ";
            generator.GeneratePdfFromFile(SOURCE, null, Path.Combine(PDF_DIRECTORY, fileName));
        }
        public void PageSizeTest()
        {
            const string fileName = "PageSize.pdf";

            HtmlToPdfConverter generator = new HtmlToPdfConverter();

            generator.Size = PageSize.A1;
            generator.GeneratePdfFromFile(SOURCE, null, Path.Combine(PDF_DIRECTORY, fileName));
        }
Exemplo n.º 6
0
        public void ConvertToPDF(string url, string output)
        {
            var _converter = new HtmlToPdfConverter();
            var fileName   = "D:/" + _exportPath + "/" + output;

            //File.WriteAllText(fileName, "asdfsdf");

            _converter.GeneratePdfFromFile(url, null, fileName);
        }
        public void GenerateByteArrayByString()
        {
            const string fileName = "GenerateByteArrayByString.pdf";

            HtmlToPdfConverter generator = new HtmlToPdfConverter();

            byte[] pdfByteArray = generator.GeneratePdfFromFile(HTML_FILE, HTML_CONTENT_COVER);

            File.WriteAllBytes(Path.Combine(PDF_DIRECTORY, fileName), pdfByteArray);
        }
Exemplo n.º 8
0
        public HttpResponseMessage DownloadClientRecords(List <ClientPartListEntity> modal)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            string fileNames             = "ClientRecords";

            try
            {
                byte[] bytes;// = new byte[file.Length];

                System.Text.StringBuilder htmlBody = new System.Text.StringBuilder();

                string htmlfilePath = AppDomain.CurrentDomain.BaseDirectory + "MailTemplate\\ClientRecords\\ClientRecords.html";
                using (System.IO.StreamReader reader = new System.IO.StreamReader((htmlfilePath)))
                {
                    htmlBody.Append(reader.ReadToEnd());
                }
                System.Text.StringBuilder sbTable = new System.Text.StringBuilder();
                foreach (var item in modal)
                {
                    sbTable.Append("<tr class='row100 body'>");
                    sbTable.Append("<td class='cell100 column1'>" + item.OrderNo + "</td>");
                    sbTable.Append("<td class='cell100 column2'>" + item.CliMatNo + "</td>");
                    sbTable.Append("<td class='cell100 column3'>" + item.RecordsOf + "</td>");
                    //sbTable.Append("<td class='cell100 column4'>" + item.Location + "</td>");
                    //sbTable.Append("<td class='cell100 column5'>" + item.Type + "</td>");
                    sbTable.Append("</tr>");
                }
                htmlBody.Replace("##TR##", sbTable.ToString());
                string fname = AppDomain.CurrentDomain.BaseDirectory + "MailTemplate\\ClientRecords\\" + DateTime.Now.ToString("MM-dd-yyyy-hhmm") + Guid.NewGuid() + ".html";
                System.IO.File.WriteAllText(fname, htmlBody.ToString());

                var htmlToPdf = new HtmlToPdfConverter();
                bytes = htmlToPdf.GeneratePdfFromFile(fname, "");

                response.Content = new ByteArrayContent(bytes);

                response.Content.Headers.Clear();
                response.Content.Headers.Add("Content-Disposition", "attachment; filename=" + fileNames + ".pdf");
                response.Content.Headers.Add("Content-Length", bytes.Length.ToString());
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping("application/pdf"));

                if (System.IO.File.Exists(fname))
                {
                    System.IO.File.Delete(fname);
                }

                return(response);
            }
            catch (Exception ex)
            {
                // response.Message.Add(ex.Message);
            }
            return(response);
        }
        public void GenerateStreamByStringAndCover()
        {
            const string fileName = "GenerateStreamByStringAndCover.pdf";

            using (MemoryStream stream = new MemoryStream())
            {
                HtmlToPdfConverter generator = new HtmlToPdfConverter();
                generator.GeneratePdfFromFile(HTML_FILE, HTML_CONTENT_COVER, stream);

                File.WriteAllBytes(Path.Combine(PDF_DIRECTORY, fileName), stream.ToArray());
            }
        }
        public ActionResult GeneratePdf(string htmlContent, string htmlUrl)
        {
            var htmlToPdf = new HtmlToPdfConverter();

            var pdfContentType = "application/pdf";

            if (!String.IsNullOrEmpty(htmlUrl))
            {
                return(File(htmlToPdf.GeneratePdfFromFile(htmlUrl, null), pdfContentType));
            }
            else
            {
                return(File(htmlToPdf.GeneratePdf(htmlContent, null), pdfContentType));
            }
        }
Exemplo n.º 11
0
 /*Converte uma página html num documento pdf*/
 internal static bool HtmlToPdf(string uri, string file)
 {
     try
     {
         HtmlToPdfConverter pdfConverter = new HtmlToPdfConverter();
         ExtensionLastFileDownloaded = ".pdf";
         pdfConverter.GeneratePdfFromFile(uri.Replace("https", "http"), null, file.EndsWith(ExtensionLastFileDownloaded) ? file : file + ExtensionLastFileDownloaded);
     }
     catch (Exception e)
     {
         RService.Log("Exception WebHandle (HtmlToPdf): " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + "RSERVICE" + ".txt");
         return(false);
     }
     return(true);
 }
Exemplo n.º 12
0
        public ActionResult GeneratePdf(string htmlContent, string htmlUrl)
        {
            var htmlToPdf = new HtmlToPdfConverter();

            var pdfContentType = "application/pdf";

            if (!String.IsNullOrEmpty(htmlUrl))
            {
                try
                {
                    return(File(htmlToPdf.GeneratePdfFromFile(htmlUrl, null), pdfContentType));
                }
                catch (Exception ex)
                {
                    return(File(htmlToPdf.GeneratePdf("<span style='color:red'><strong> DOMAIN NOT FOUND </strong></span>", null), pdfContentType));
                }
            }
            else
            {
                return(File(htmlToPdf.GeneratePdf(htmlContent, null), pdfContentType));
            }
        }
Exemplo n.º 13
0
        private async Task <byte[]> PdfConverter(string fileName)
        {
            //html = "<div class='col-sm-12'><img src='" + Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") +
            //        "/Images/Barcode-ObservationConsultation.jpg' height='70' width='126' style='float:right'/><div style='clear:both'></div></div>" + html;

            string viewHtml = string.Empty;

            viewHtml = await _viewRenderService.RenderViewToStringAsync(this.ControllerContext, "LoanApplication", new LoanViewModel(), TempData);


            string applicationFormFilePath       = _applicationFormDirectorypath + "/" + fileName;
            string applicationFormOutputFilePath = _applicationFormDirectorypath + "/Generated_" + fileName;

            if (!Directory.Exists(_applicationFormDirectorypath))
            {
                Directory.CreateDirectory(_applicationFormDirectorypath);
            }

            System.IO.File.WriteAllText(applicationFormFilePath, viewHtml, Encoding.UTF8);



            //var headerText = "<br/><b>" + patient.SName + ", " + patient.FName + "</b>&nbsp;&nbsp;&nbsp;&nbsp;PAS No: " + patient.PasNo + "&nbsp;&nbsp;&nbsp;&nbsp;DOB: " + (string.IsNullOrEmpty(patient.DOB) ? "N/A" : dob.ToString("dd/MM/yyyy")) + (string.IsNullOrEmpty(patient.NHS_No) ? "" : " NHS No :" + patient.NHS_No);

            byte[] convertedPdfBytes;

            try
            {
                var pdfConverter = new HtmlToPdfConverter
                {
                    //PageHeaderHtml = "",
                    Orientation = PageOrientation.Portrait,
                    LowQuality  = false,
                    Margins     = new PageMargins {
                        Bottom = 20, Left = 10, Right = 10, Top = 20
                    },
                    //PageFooterHtml =
                    //    "<center><small>Generated by Our Clinic Report Generator on " + DateTime.Now.ToString("dd MMMM yyyy HH:mm:ss") + "<span class='page'></span>" +
                    //"</center></small>"
                };

                //pdfConverter.PageHeaderHtml = headerText + "<div style='vertical-align: middle; font-size: 12px;font-weight:bold; color: #fff;background-color:#007fff;margin: 20px 0px 10px 0px; padding: 5px 5px;float:right'>Page <b class='page'></b> of <b class='topage'></b></div><div style='clear:both;'></div>";


                convertedPdfBytes = pdfConverter.GeneratePdfFromFile(applicationFormFilePath, null);//Creates pdf very quickly from html file than content itself

                System.IO.File.WriteAllBytes(_applicationFormDirectorypath + "/ " + Path.GetFileNameWithoutExtension(fileName) + ".pdf", convertedPdfBytes);

                //if (!ignoreDownload)
                //{
                //    Response.Clear();
                //    var ms = new MemoryStream(convertedPdfBytes);
                //    Response.ContentType = "application/pdf";
                //    Response.AddHeader("Refresh", "3;URL=/Clinic/ClinicPatientManager.aspx");
                //    Response.AddHeader("content-disposition", "attachment;filename=PatientClinicalInfo_" + Path.GetFileNameWithoutExtension(fileName) + ".pdf");
                //    Response.Buffer = true;
                //    ms.WriteTo(Response.OutputStream);
                //    Response.End();
                //}
            }
            catch (Exception ex)
            {
                convertedPdfBytes = null;
            }
            return(convertedPdfBytes);
        }
Exemplo n.º 14
0
        public ActionResult Generate(GenerateViewModel viewModel)
        {
            var theDate = DateTime.ParseExact(viewModel.Date, "MM/dd/yyyy", CultureInfo.InvariantCulture).AddDays(1);
            var htmlToPdf = new HtmlToPdfConverter();
            htmlToPdf.Size = PageSize.A3;
            if (!Directory.Exists(Server.MapPath(PathConstant.DerPath)))
            {
                Directory.CreateDirectory(Server.MapPath(PathConstant.DerPath));
            }
            int revision = 0;
            var isExisted = _derService.IsDerExisted(theDate, out revision);
            revision = isExisted ? (revision + 1) : revision;
            var title = "DER/" + theDate.ToString("dd-MMM-yyyy");
            var pdfName = string.Format("{0}_{1}.pdf", title.Replace('/', '-'), revision);
            var pdfPath = Path.Combine(Server.MapPath(PathConstant.DerPath), pdfName);
            var secretNumber = Guid.NewGuid().ToString();
            var secretPath = Path.Combine(Server.MapPath(PathConstant.DerPath), secretNumber + ".txt");
            System.IO.File.WriteAllText(secretPath, viewModel.Content);
            var displayUrl = Url.Action("Preview", "DerImage", new { secretNumber = secretNumber }, this.Request.Url.Scheme);
            htmlToPdf.Margins.Top = 20;
            htmlToPdf.Margins.Bottom = 20;
            htmlToPdf.Margins.Left = 20;
            htmlToPdf.Margins.Right = 20;
            htmlToPdf.GeneratePdfFromFile(displayUrl, null, pdfPath);
            var response = _derService.CreateOrUpdate(new CreateOrUpdateDerRequest
            {
                Filename = PathConstant.DerPath + "/" + pdfName,
                Title = title,
                Date = theDate,
                RevisionBy = UserProfile().UserId
            });
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return base.ErrorPage(response.Message);
            //htmlToPdf.GeneratePdfFromFile(displayUrl, null, pdfPath);
            //return File(pdfPath, "application/pdf");
            //var htmlToImageConverter = new HtmlToImageConverter();
            //htmlToImageConverter.Height = 2481;
            //htmlToImageConverter.Width = 1754;
            //return File(htmlToImageConverter.GenerateImageFromFile(displayUrl, ImageFormat.Png), "image/png", "TheGraph.png");
        }
Exemplo n.º 15
0
        public async Task <dynamic> PrintReport(string screen, string complaintId)
        {
            string html     = string.Empty;
            string filename = string.Empty;
            NewWarrantyComplaintManager _warranty = new NewWarrantyComplaintManager();

            try
            {
                var response = await _warranty.GetPrintReportByReportName(screen, complaintId);

                switch (screen)
                {
                case "5":
                    html = ReadHTML(@"~\Content\PDFContent\Create_Report_CustFeedback_rpt.htm");
                    foreach (var data in response)
                    {
                        html = html.Replace("#Status", data.StatusReport);
                        html = html.Replace("#ComplaintID", complaintId);
                        html = html.Replace("#FollowUpDate", Convert.ToString(data.FollowUpDueDate));
                        html = html.Replace("#ActualFollowUpDate", Convert.ToString(data.ActualFollowUpDate));
                        html = html.Replace("#MethodOfFollowUp", data.FollowupMethod);
                        html = html.Replace("#FollowUpBy", data.FollowupConductedByName);
                        html = html.Replace("#CustomerDetails", data.ContactDetails);
                        html = html.Replace("#DateReceivedFeedBack", Convert.ToString(data.ReceivedFeedbackDate));
                        html = html.Replace("#DescriptionOfFeedback", data.DescriptionFeedback);
                        html = html.Replace("#AdditionalActionRequired", Convert.ToBoolean(data.AdditionalActionRequiredFlag) == false?"":"checked='checked'");
                        html = html.Replace("#AdditionalAction", data.AdditionalAction);
                        html = html.Replace("#DateActionCompleted", Convert.ToString(data.ClosingDate));
                        html = html.Replace("#ActionCompletedBy", data.ClosedByName);
                    }
                    break;

                case "3":
                    html = ReadHTML(@"~\Content\PDFContent\Create_Report_Warranty_rpt.htm");
                    foreach (var data in response)
                    {
                        html = html.Replace("#Status", data.StatusReport);
                        html = html.Replace("#ComplaintID", complaintId);
                        html = html.Replace("#DateReceived", Convert.ToString(data.DateReceived));
                        html = html.Replace("#Recipient", data.Recipient);
                        html = html.Replace("#TimeLogged", Convert.ToString(data.TimeLogged));
                        html = html.Replace("#LoggedBy", data.LoggedBy);
                        html = html.Replace("#DateLogged", Convert.ToString(data.DateLogged));
                        html = html.Replace("#Manager", data.Manager);

                        html = html.Replace("#Phone", Convert.ToBoolean(data.FormatComplaintPhone) == false ? "" : "checked='checked'");
                        html = html.Replace("#chkEmail", Convert.ToBoolean(data.FormatComplaintEmail) == false ? "" : "checked='checked'");
                        html = html.Replace("#Postal", Convert.ToBoolean(data.FormatCompaintPostal) == false ? "" : "checked='checked'");
                        html = html.Replace("#SocialMedia", Convert.ToBoolean(data.FormatComplaintSocialMedia) == false ? "" : "checked='checked'");
                        html = html.Replace("#InPerson", Convert.ToBoolean(data.FormatComplaintPerson) == false ? "" : "checked='checked'");

                        html = html.Replace("#Ref", Convert.ToString(data.AccountRef));
                        html = html.Replace("#AccountName", data.AccountName);
                        html = html.Replace("#Address1", data.AccountAddress1);
                        html = html.Replace("#Address2", data.AccountAddress2);
                        html = html.Replace("#City", data.TownCity);
                        html = html.Replace("#Postal", data.PostCode);
                        html = html.Replace("#Department", data.Department);
                        html = html.Replace("#Title", data.Title);
                        html = html.Replace("#FirstName", data.FirstName);
                        html = html.Replace("#LastName", data.LastName);
                        html = html.Replace("#JobTitle", data.JobTitle);
                        html = html.Replace("#TelNo", data.TelNo);
                        html = html.Replace("#Ext", "");
                        html = html.Replace("#Email", data.Email);

                        html = html.Replace("#Human", Convert.ToBoolean(data.AccountTypeHuman) == false ? "" : "checked='checked'");
                        html = html.Replace("#Vet", Convert.ToBoolean(data.AccountTypeVeterinary) == false ? "" : "checked='checked'");
                        html = html.Replace("#Industrial", Convert.ToBoolean(data.AccountTypeIndustrial) == false ? "" : "checked='checked'");

                        html = html.Replace("#WCC", data.ComplaintCategory);
                        html = html.Replace("#Reliability", Convert.ToBoolean(data.ProductReliability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Identity", Convert.ToBoolean(data.ProductIdentiy) == false ? "" : "checked='checked'");
                        html = html.Replace("#Performance", Convert.ToBoolean(data.ProductPerformance) == false ? "" : "checked='checked'");
                        html = html.Replace("#Quality", Convert.ToBoolean(data.ProductQuality) == false ? "" : "checked='checked'");
                        html = html.Replace("#Usability", Convert.ToBoolean(data.ProductUsability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Durability", Convert.ToBoolean(data.ProductDurability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Safety", Convert.ToBoolean(data.ProductSafety) == false ? "" : "checked='checked'");
                        html = html.Replace("#DWC", data.SummaryComplaint);
                    }

                    break;

                case "4":
                    filename = complaintId + "_" + "CommunicationLog.pdf";
                    html     = ReadHTML(@"~\Content\PDFContent\Create_Report_Comms_Log_rpt.htm");
                    foreach (var data in response)
                    {
                        html = html.Replace("#PrintSummaryComm", data.SummaryComms);
                        html = html.Replace("#PrintCommsLogStatus", data.StatusReport);
                        html = html.Replace("#PrintComplaintID", data.ComplaintID.ToString());
                    }
                    break;

                case "2":
                    filename = complaintId + "_" + "AdverseIncident.pdf";
                    html     = ReadHTML(@"~\Content\PDFContent\Create_Report_MHRA_rpt.html");
                    foreach (var data in response)
                    {
                        html = html.Replace("#ComplaintID", complaintId);
                        html = html.Replace("#ProductDetails", "");
                        html = html.Replace("#DateOfEvent", Convert.ToString(data.EventDate));

                        html = html.Replace("#HAEO", Convert.ToBoolean(data.HasEventOccurredFlag) == false?"":"checked='checked'");
                        html = html.Replace("#HAEO15", Convert.ToBoolean(data.DeathInjuryFlag) == false ? "" : "checked='checked'");
                        html = html.Replace("#HAEO10", Convert.ToBoolean(data.CouldDeathInjuryFlag) == false ? "" : "checked='checked'");

                        html = html.Replace("#DOIorD", data.DetailsDeathInjury);

                        html = html.Replace("#DATI", Convert.ToBoolean(data.KarlStorzDeviceFlag) == false ? "" : "checked='checked'");
                        html = html.Replace("#DMITE", Convert.ToString(data.InitialIncidentEmailDate));

                        html = html.Replace("#Manufacturer", data.ManufacturerName);

                        html = html.Replace("#AICMorVURR", Convert.ToBoolean(data.CriteriaMetFlag) == false ? "" : "checked='checked'");
                        html = html.Replace("#WIRBTUTMHRA", Convert.ToBoolean(data.ReportedMHRAUserFlag) == false ? "" : "checked='checked'");
                        html = html.Replace("#DURtoMHRA", Convert.ToString(data.MHRAReportedUserDate));

                        html = html.Replace("#WIRYes", Convert.ToBoolean(data.ReportedMHRAKSEUKFlag) == false ? "" : "checked='checked'");
                        html = html.Replace("#WIRNo", Convert.ToBoolean(data.ReportedMHRAKSEUKNoFlag) == false ? "" : "checked='checked'");

                        html = html.Replace("#DKSEUKRToMHRA", Convert.ToString(data.MHRAReportedDate));
                        html = html.Replace("#KSEUKMHRARef", Convert.ToString(data.MHRARef));
                        html = html.Replace("#CMHRARef", Convert.ToString(data.CustomerMHRARef));
                        html = html.Replace("#DASToMHRA", Convert.ToString(data.KSEUKAckMHRADate));
                        html = html.Replace("#DNRD", Convert.ToString(data.ReportReceivedKSTDate));
                        html = html.Replace("#DFMRR", Convert.ToString(data.NextReportMFGDate));
                        html = html.Replace("#DRSTMHRA", Convert.ToString(data.ReportSentMHRADate));
                        html = html.Replace("#DCLRFMHRA", Convert.ToString(data.ClosingLetterReceivedMHRADate));

                        html = html.Replace("#MRtoMHRA", Convert.ToBoolean(data.Mfg_Report_MHRA_Flag) == false ? "" : "checked='checked'");
                        html = html.Replace("#NtobeRMHRA", Convert.ToBoolean(data.MfgNotReportMHRAFlag) == false ? "" : "checked='checked'");

                        html = html.Replace("#InvestOutCome", data.InvestigationOutcome);
                        html = html.Replace("#Comments", data.MHRAComments);
                    }
                    break;

                case "1":
                    filename = complaintId + "_" + "FullComplaintReport.pdf";
                    html     = ReadHTML(@"~\Content\PDFContent\Create_Report_Full_Complaint_rpt.htm");
                    foreach (var data in response)
                    {
                        html = html.Replace("#Status", data.StatusReport);
                        html = html.Replace("#ComplaintID", complaintId);
                        html = html.Replace("#DateReceived", Convert.ToString(data.DateReceived));
                        html = html.Replace("#Recipient", data.Recipient);
                        html = html.Replace("#TimeLogged", Convert.ToString(data.TimeLogged));
                        html = html.Replace("#LoggedBy", data.LoggedBy);
                        html = html.Replace("#DateLogged", Convert.ToString(data.DateLogged));
                        html = html.Replace("#Manager", data.Manager);

                        html = html.Replace("#Phone", Convert.ToBoolean(data.FormatComplaintPhone) == false ? "" : "checked='checked'");
                        html = html.Replace("#chkEmail", Convert.ToBoolean(data.FormatComplaintEmail) == false ? "" : "checked='checked'");
                        html = html.Replace("#Postal", Convert.ToBoolean(data.FormatCompaintPostal) == false ? "" : "checked='checked'");
                        html = html.Replace("#SocialMedia", Convert.ToBoolean(data.FormatComplaintSocialMedia) == false ? "" : "checked='checked'");
                        html = html.Replace("#InPerson", Convert.ToBoolean(data.FormatComplaintPerson) == false ? "" : "checked='checked'");

                        html = html.Replace("#Ref", Convert.ToString(data.AccountRef));
                        html = html.Replace("#AccountName", data.AccountName);
                        html = html.Replace("#Address1", data.AccountAddress1);
                        html = html.Replace("#Address2", data.AccountAddress2);
                        html = html.Replace("#City", data.TownCity);
                        html = html.Replace("#Postal", data.PostCode);
                        html = html.Replace("#Department", data.Department);
                        html = html.Replace("#Title", data.Title);
                        html = html.Replace("#FirstName", data.FirstName);
                        html = html.Replace("#LastName", data.LastName);
                        html = html.Replace("#JobTitle", data.JobTitle);
                        html = html.Replace("#TelNo", data.TelNo);
                        html = html.Replace("#Ext", "");
                        html = html.Replace("#Email", data.Email);

                        html = html.Replace("#Human", Convert.ToBoolean(data.AccountTypeHuman) == false ? "" : "checked='checked'");
                        html = html.Replace("#Vet", Convert.ToBoolean(data.AccountTypeVeterinary) == false ? "" : "checked='checked'");
                        html = html.Replace("#Industrial", Convert.ToBoolean(data.AccountTypeIndustrial) == false ? "" : "checked='checked'");

                        html = html.Replace("#WCC", data.ComplaintCategory);
                        html = html.Replace("#Reliability", Convert.ToBoolean(data.ProductReliability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Identity", Convert.ToBoolean(data.ProductIdentiy) == false ? "" : "checked='checked'");
                        html = html.Replace("#Performance", Convert.ToBoolean(data.ProductPerformance) == false ? "" : "checked='checked'");
                        html = html.Replace("#Quality", Convert.ToBoolean(data.ProductQuality) == false ? "" : "checked='checked'");
                        html = html.Replace("#Usability", Convert.ToBoolean(data.ProductUsability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Durability", Convert.ToBoolean(data.ProductDurability) == false ? "" : "checked='checked'");
                        html = html.Replace("#Safety", Convert.ToBoolean(data.ProductSafety) == false ? "" : "checked='checked'");
                        html = html.Replace("#DWC", data.SummaryComplaint);
                    }
                    break;
                }
                //Byte[] res = null;
                //using (MemoryStream ms = new MemoryStream())
                //{
                //    var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);
                //    pdf.Save(ms);
                //    res = ms.ToArray();
                //}
                //var contentLength = res.Length;
                //Response.AppendHeader("Content-Length", contentLength.ToString());
                //Response.AppendHeader("Content-Disposition", "inline; filename=" + filename);
                //return new FileContentResult(res, "application/pdf")
                //{
                //    FileDownloadName = "CommsLog.pdf"
                //};

                var    htmlToPdf      = new HtmlToPdfConverter();
                string htmlUrl        = "";
                var    pdfContentType = "application/pdf";
                if (!String.IsNullOrEmpty(htmlUrl))
                {
                    return(File(htmlToPdf.GeneratePdfFromFile(htmlUrl, null), pdfContentType));
                }
                else
                {
                    return(new FileContentResult(htmlToPdf.GeneratePdf(html, null), pdfContentType)
                    {
                        FileDownloadName = "CommsLog.pdf"
                    });
                }
            }
            catch (Exception ex)
            {
                WriteLogToFile(ex.Message.ToString() + "<====>" + ex.StackTrace.ToString());
                throw ex;
            }
        }