I'm using NReco to convert HTML views to PDF files in a C# project. Everything works perfectly but I'm struggling to set the Font-Family
and Font-Size
properties of the generated ToC as it doesnt match the rest of the document.
This is my code currently:
var pdfConverter = new HtmlToPdfConverter
{
Orientation = PageOrientation.Landscape,
PageFooterHtml = "<div style=\"font-family: Arial;\">Page: <span class=\"page\"></span> of <span class=\"topage\"></span></div>",
GenerateToc = true
};
There is a property available called CustomWkHtmlTocArgs
that I know I should be using to solve this but I don't know what to assign to this variable.
I think I need to create a XSLT
style sheet or something?
Your suggestion is correct, NReco.PdfGenerator internally uses wkhtmltopdf and if you want to change default TOC layout and/or styles you need to specify custom XSL for TOC:
pdfConverter.CustomWkHtmlTocArgs = " --xsl-style-sheet full_path_to_your_toc.xsl ";
To get sample (default) XSL file run:
> wkhtmltopdf.exe --dump-default-toc-xsl > toc.xsl
You can get more details about wkhtmltopdf options here: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt