本文介绍了iText禁用打印/复制/保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个servlet来使用iText来提供PDF。有没有办法从浏览器端禁用打印/复制/保存?

I wrote a servlet to serve PDF using iText. Is there any way to disable printing/Copying/Saving from the browser end?

推荐答案

这是。这个想法是你必须加密PDF以保护各种用户操作。

Here's a thread that provides the relevant magic API invocation. The idea is that you have to encrypt the PDF in order to protect various user operations.

PdfReader reader = new PdfReader("my-old-file.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my-new-file.pdf"));
stamper.setEncryption("my-owner-password".getBytes(), "my-user-password".getBytes(),
    PdfWriter.AllowPrinting | PdfWriter.AllowCopy, PdfWriter.STRENGTH40BITS);
stamper.close();

这篇关于iText禁用打印/复制/保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 06:42