简体   繁体   中英

NReco HTML to PDF turn off Table of Contents generation

I'm trying to set up NReco HTML to PDF generation and having an issue. It generates the PDF but when I open the PDF with adobe reader, it automatically opens the "Bookmarks" side tab consuming quite a bit of screen real estate (about 1/3 of the window).

This is unnecessary, because the PDF is one page long. From what I can tell, this is because the PDF has a table of contents generated by taking the HTML header elements.

I updated my code to attempt to turn of table of contents generation:

        var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter
        {
            GenerateToc = false
        };

        var byteArray = htmlToPdf.GeneratePdf(emailHtmlBody);

        var memStream = new MemoryStream(byteArray);

        return memStream;

but making this change seems to have no effect. Any help with this would be greatly appreciated.

it automatically opens the "Bookmarks" side tab

this is not a table of contents in fact; in terms of wkhtmltopdf (which is internally used by NReco.PdfGenerator) this is called 'outline' and you can disable its generation by H1-H6 tags in the following way:

htmlToPdf.CustomWkHtmlArgs = " --no-outline ";

Complete list of wkhtmltopdf options may be found here: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM