Abcpdf 可复制/可选择文本

发布于 2025-01-04 08:26:56 字数 1213 浏览 2 评论 0原文

我正在使用 websupergoos abcpdf 通过 addimageurl 将 html 页面转换为 pdf。

效果很好,但生成的 pdf 不允许用户选择文本和复制。一切都是一个“图像”。

可以这样做吗?要使用哪些设置?

这是我当前的代码。评论的“扁平化”似乎没有做任何相关的事情。 HttpStream 只是将 pdf 作为文档转发给用户。

            var doc = new Doc();
            doc.HtmlOptions.UseScript = true;

            doc.Units = "mm";
            doc.MediaBox.String = "0 0 210 297";
            doc.Rect.String = doc.MediaBox.String;
            doc.Rect.Inset(10.0, 10.0);
            doc.SetInfo(0, "License", abcpdfkey);
            doc.HtmlOptions.UseScript = true;
            doc.HtmlOptions.AddMovies = true;

            doc.HtmlOptions.RetryCount = 0;
            doc.HtmlOptions.ContentCount = 1;


                doc.Page = doc.AddPage();
                for (int i = doc.AddImageUrl(url); doc.Chainable(i); i = doc.AddImageToChain(i))
                {
                    doc.Page = doc.AddPage();
                }

                int pageCount = doc.PageCount;
                for (int j = 1; j <= pageCount; j++)
                {
                    doc.PageNumber = j;
                 //   doc.Flatten();
                }

                this.HttpStream(doc.GetData(), filename);

i'm using websupergoos abcpdf to convert html pages to pdf via addimageurl.

Works great, but the resulting pdf does not allow the user to select text and copy. All is one 'image'.

Is it possible to do this? Which are the settings to use?

This is my current code. The commented "flatten" does not seem to do anything relevant. The HttpStream simply forewards the pdf to users as a doc.

            var doc = new Doc();
            doc.HtmlOptions.UseScript = true;

            doc.Units = "mm";
            doc.MediaBox.String = "0 0 210 297";
            doc.Rect.String = doc.MediaBox.String;
            doc.Rect.Inset(10.0, 10.0);
            doc.SetInfo(0, "License", abcpdfkey);
            doc.HtmlOptions.UseScript = true;
            doc.HtmlOptions.AddMovies = true;

            doc.HtmlOptions.RetryCount = 0;
            doc.HtmlOptions.ContentCount = 1;


                doc.Page = doc.AddPage();
                for (int i = doc.AddImageUrl(url); doc.Chainable(i); i = doc.AddImageToChain(i))
                {
                    doc.Page = doc.AddPage();
                }

                int pageCount = doc.PageCount;
                for (int j = 1; j <= pageCount; j++)
                {
                    doc.PageNumber = j;
                 //   doc.Flatten();
                }

                this.HttpStream(doc.GetData(), filename);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2025-01-11 08:26:56

在将 PDF 发送到 HTTP 流之前,您可以设置加密属性

CanCopy 属性设置用户是否可以从 PDF 复制文本

要设置它,请添加以下代码:

doc.Encryption.CanCopy = true;

您可能还需要设置 doc.Encryption.CanExtract

Before sending the PDF to the HTTP stream, you can set the encryption properties

The CanCopy Property sets if the user can copy text from the PDF

To set it add the following code:

doc.Encryption.CanCopy = true;

You may need to set doc.Encryption.CanExtract as well

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文