I have referred below link for doing a html to pdf conversion
https://www.syncfusion.com/kb/8483/how-to-convert-html-to-pdf-in-asp-net-core-windows
I have used .net core 3.1 and Qbinaries version 19, but getting blank PDF. Front end angular is used.
code is like this.
[HttpGet("ExportToPDF")]
public IActionResult ExportToPDF()
{
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = Path.Combine(hostingEnvironment.ContentRootPath, "QtBinariesWindows");
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
MemoryStream stream = new MemoryStream();
document.Save(stream);
document.Close(true);
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf");
}
EDIT:-
After installing open ssl libraries, now getting PDF for " https://www.google.com", but when i am giving some local URL(http://localhost:4200/#/simetry/visualizations/dashboards/1) getting blank PDF.
tried adding, used for authorization
settings.HttpRequestHeaders.Add("Authorization", "Bearer ");
even token too.
settings.Cookies.Add("TOKEN", "");
Even it is not exporting the landing page.
Request you to suggest.
//Set additional delay; units in milliseconds
Settings.AdditionalDelay = 4000; |