public string GetUrlToPdf(string url)
        {
            string pdfFileName   = _pdfController.UrlToFileName(url);
            string converterPath = _pdfController.Server.MapPath("~") + _localAppDirectory + "\\create_pdf_from_html.bat";
            string pdfFilePath   = _pdfController.Server.MapPath("~") + "Content\\" + pdfFileName;
            string arguments     = url + " " + pdfFilePath;

            ProcessStartInfo startInfo = new ProcessStartInfo(converterPath, arguments)
            {
                UseShellExecute  = false,
                CreateNoWindow   = true,
                WorkingDirectory = _pdfController.Server.MapPath("~") + _localAppDirectory + "\\"
            };

            Process process = Process.Start(startInfo);

            process.WaitForExit();

            UriBuilder urlBuilder = new UriBuilder(_pdfController.Request.Url.AbsoluteUri)
            {
                Path  = _pdfController.Url.Content("~/Content/" + pdfFileName),
                Query = null,
            };

            return(urlBuilder.ToString());
        }
        public string GetUrlToPdf(string url)
        {
            HtmlCleanerInjector injector = new HtmlCleanerInjector(new BaseInjectorConfig(), new WebCleanerConfigSerializer(_pdfController.Server));
            //  Creating cleaner instance based on URL.
            IHtmlCleaner processChain = injector.CreateHtmlCleaner(url);

            //  Performs request.
            string s = HtmlCleanerApp.MakeRequest(url);

            _ = processChain.Process(s);

            ITagFormatter formatter = processChain.GetFormatter();

            //  Finishes processing.
            formatter.CloseDocument();
            using (MemoryStream dataStream = formatter.GetOutputStream())
            {
                string pdfFileName = _pdfController.UrlToFileName(url);
                string pdfFilePath = _pdfController.GetContentPath(pdfFileName);

                if (dataStream != null)
                {
                    using (FileStream fileStream = System.IO.File.Create(pdfFilePath))
                    {
                        dataStream.Seek(0, SeekOrigin.Begin);
                        dataStream.CopyTo(fileStream);
                    }
                }

                return(_pdfController.GetContentUri(pdfFileName));
            }
        }