In my console application (.NET Core 2.2) I have a HTML string created with:
StringBuilder sb = new StringBuilder();
sb.Append(@"<head>");
sb.Append(@"<link href='"+ AAAA + "' rel='stylesheet'/>");
sb.Append(@"</head>");
sb.Append(@"<body>");
sb.Append(@"<h1>test</h1>");
sb.Append(@"</body>");
return sb.ToString();
Where AAAA = Path.Combine(@"file:///C:/Users/asus/Desktop/IT/!!Trials!!/02_APIs/HtmlToPdf_06_CV_Spike/HtmlToPdf/bin/Debug/netcoreapp2.2/styles.css");
is file path, regarding https://github.com/rdvojmoc/DinkToPdf/issues/27#issuecomment-417792667
And it does not work for me. Style sheet does not changes styles on HTML. I also tried sb.Append(@"<link href='styles.css' rel='stylesheet'/>");
with the same result.
Please note, that styles.css
file is located in project main folder, also in (...)Debug/netcoreapp2.2
.
Actually I ran out of ideas and inspirations, from here and SO, how to make my HTML to use CSS in my console application. Is it possible at all? Thank you in advance for your help.
Project tree:
Allright, I found solution:
https://stackoverflow.com/a/20357784/12603542
Need also add: file:///
before.
private static string CreateHtmlHead()
{
StringBuilder sb = new StringBuilder();
sb.Append(@"<head>");
sb.Append(@"<link href='file:///C:\Users\asus\Desktop\IT\!!Trials!!\02_APIs\HtmlToPdf_06_CV_Spike\HtmlToPdf\bin\Debug\netcoreapp2.2\styles.css' rel='stylesheet' type='text/css' media='screen'/>");
sb.Append(@"</head>");
return sb.ToString();
}