public string GetUrlToPdf(string url) { string fileName = RequestConvertingService(url); GetFileFromConvertingService(fileName); return(_pdfController.GetContentUri(fileName)); }
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)); } }