//Get diagram page URL,
string url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Diagram/DiagramFeatures";
HtmlToPdfResult result = renderer.Convert(url, (int)width, (int)height); |
//Converting partial Web page to PDF using HTML element ID
HtmlToPdfResult result = renderer.ConvertPartialHtml(url, "ControlRegion", (int)width, (int)height); |
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"C:\QtBinaries";
//Add cookies required for Authentication
webKitSettings.Cookies.Add("Key1", "Value1");
webKitSettings.Cookies.Add("Key2", "Value2");
webKitSettings.AdditionalDelay = 5000;
htmlConverter.ConverterSettings = webKitSettings;
//Convert url to pdf
PdfDocument document = htmlConverter.Convert("http://example.com");
//Save and close the document
document.Save("Output.pdf");
document.Close(true); |
public void ExportSeatingPlan() { HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); //WebKit converter settings WebKitConverterSettings webKitSettings = new WebKitConverterSettings(); //Assign the WebKit binaries path webKitSettings.WebKitPath = @"C:/Program Files (x86)/Syncfusion/WebKitHTMLConverter/15.1.0.33/QtBinaries"; //Add cookies required for Authentication webKitSettings.Cookies.Add("UserName", "xxx"); webKitSettings.Cookies.Add("Password", "xxx"); webKitSettings.AdditionalDelay = 5000; htmlConverter.ConverterSettings = webKitSettings; string url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Plan/ViewPlan?PlanId=" + Session["PlanID"] + "&ClassId=" + Session["ClassID"] + "&LayoutId=" + Session["LayoutID"]; //Convert url to pdf PdfDocument document = htmlConverter.ConvertPartialHtml(url, "LayoutTemplate"); //Save and close the document document.Save("Sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Open); document.Close(true); System.Diagnostics.Process.Start("Sample.pdf"); }