简体   繁体   English

NReco HTML to PDF 关闭目录生成

[英]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.我正在尝试将 NReco HTML 设置为 PDF 生成并遇到问题。 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).它会生成 PDF,但是当我使用 adobe 阅读器打开 PDF 时,它会自动打开“书签”侧选项卡,消耗相当多的屏幕空间(大约窗口的 1/3)。

This is unnecessary, because the PDF is one page long.这是不必要的,因为 PDF 是一页长。 From what I can tell, this is because the PDF has a table of contents generated by taking the HTML header elements.据我所知,这是因为 PDF 有一个通过 HTML 标题元素生成的目录。

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:就 wkhtmltopdf(由 NReco.PdfGenerator 内部使用)而言,这称为“大纲”,您可以通过以下方式通过 H1-H6 标签禁用其生成:

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

Complete list of wkhtmltopdf options may be found here: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt可以在此处找到 wkhtmltopdf 选项的完整列表: https ://wkhtmltopdf.org/usage/wkhtmltopdf.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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