-1

我想禁用选择,就像图像一样,即使包含文本。

我知道 PDF 包含图层,但我找不到删除文本图层的位置。

谢谢。

        var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
        htmlToPdf.Size = NReco.PdfGenerator.PageSize.Letter;

        htmlToPdf.Margins = new NReco.PdfGenerator.PageMargins()
        {
            Bottom = 0,
            Top = 0,
            Left = 0,
            Right = 0
        };
        string ID = "Test";
        Response.ContentType = "application/pdf";

        Response.AppendHeader("content-disposition", string.Format("inline;FileName=\"{0}.pdf\"", ID));

        htmlToPdf.GeneratePdfFromFile("Page.aspx", null, Response.OutputStream);

        Response.End();
4

1 回答 1

0

PdfGenerator 内部使用 wkhtmltopdf 并将文本内容呈现为文本块,默认情况下它们是可选的;这种行为无法改变。如果您想保证不能选择文本,则应将其呈现为图像(= 您可以先将 HTML 呈现为图像,然后生成包含该图像的 PDF)。

另一种选择是使用 iTextSharp 加密生成的 PDF,请参阅Lock PDF against editing using iTextSharp的答案 - 只有 PdfWriter.ALLOW_PRINTING 选项(iTextSharp 的 LGPL 版本 4.1.6 可用于此目的)。

于 2017-07-28T06:22:44.477 回答