fpanaccia / Wkhtmltopdf.NetCore-deprecated

Rotativa + Net Core
The Unlicense
220 stars 94 forks source link

Using header with string HTML #61

Closed MauriceChocoSwiss closed 3 years ago

MauriceChocoSwiss commented 3 years ago

Hi, i want to use the HeaderHTML option to add some headers. My project is an API and i use razorViewToString to render my dynamic header in a string. But it doesn't work if i place it in the header option.

It's normal ? It accept only string URL ?

MauriceChocoSwiss commented 3 years ago

Here is my solution

using (FileStream fs = new FileStream("header.html", FileMode.Create))
{
     using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
     {
           w.WriteLine(headerHTML);
     }
}

var options = new ConvertOptions
{
     HeaderHtml = "header.html"
}