I have the following function that creates a PDF of a HTML page.
[Authorize]
public FileStreamResult PDFCV(int Id)
{
var user = _userManager.GetUserAsync(User);
HtmlToPdf converter = new HtmlToPdf();
var BaseUrl = HttpContext.Request.Host;
var Path = Url.Action("PreviewCv", "Cv", new { Id = Id });
try
{
converter.Options.HttpCookies.Add(".AspNetCore.Identity.Application", HttpContext.Request.Cookies[".AspNetCore.Identity.Application"]);
}
catch (Exception e)
{
Console.WriteLine(e);
}
string url = "";
try
{
url = BaseUrl + Path;
}
catch (Exception e)
{
Console.WriteLine(e);
}
try
{
PdfDocument doc = converter.ConvertUrl(url);
var PdfArray = doc.Save();
doc.Close();
return new FileStreamResult(new MemoryStream(PdfArray), "application/pdf");
}
catch (Exception e)
{
Console.WriteLine(e);
}
return new FileStreamResult(new MemoryStream(), "application/pdf");
}
This function allows me to get the PDF of the HTML page.
However it seems like it is not able to add the external CSS.
I have added it to the head of the HTML file.
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat"
</head>
When I access the page directly "/PDFPreview", I get the correct CSS.
Any suggestions on how I could force SelectPDF to use the correct CSS?