try { string html; if (string.IsNullOrEmpty(tbUrl.Text.Trim())) { throw new ApplicationException("The URL is empty."); } using (var client = new WebClient()) { html = client.DownloadString(tbUrl.Text); } //Transform the HTML into PDF var pechkin = Factory.Create(new GlobalConfig()); var pdf = pechkin.Convert(new ObjectConfig() .SetLoadImages(true).SetZoomFactor(1.5) .SetPrintBackground(true) .SetScreenMediaType(true) .SetCreateExternalLinks(true), html); //Return the PDF file Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=test.pdf; size={0}", pdf.Length)); Response.BinaryWrite(pdf); Response.Flush(); Response.End(); } catch (Exception ex) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)