Created
December 20, 2022 15:41
-
-
Save KennethScott/eb73951ee150beb2fe6e40c49633288d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}"; | |
//var baseUrl = "D:\\home\\site\\wwwroot\\wwwroot"; | |
IronPdf.Logging.Logger.EnableDebugging = true; | |
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.File; | |
IronPdf.Logging.Logger.LogFilePath = "IronPdf.txt"; | |
var cookies = Request.Cookies; | |
Dictionary<string, string> customCookies = cookies.ToDictionary(c => c.Key, c => c.Value); | |
var newPdf = new HtmlToPdf | |
{ | |
PrintOptions = new ChromePdfRenderOptions | |
{ | |
CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print, | |
}, | |
LoginCredentials = new ChromeHttpLoginCredentials | |
{ | |
CustomCookies = customCookies, | |
EnableCookies = true | |
} | |
}; | |
return await newPdf.RenderHtmlAsPdfAsync(html, new Uri(baseUrl)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment