1.通过iText怎样对PDF加密(只是普通加密,非认证加密)。 2.在JSP页面中显示PDF时,怎样禁止右键菜单(只禁止右键菜单中的“打印”选项也行)。 3.在后台或在JSP页面中怎样启用/禁用PDF的“打印”功能(打印时不弹出属性对话框)。

解决方案 »

  1.   

    1,itext没用过,一般itext中对应的借口和方法,看问档
    2,js处理
    3,不太明白,不是要后台或jsp去控制阅读pdf工具的打印把...
      

  2.   

    加密
    打开文档之前还要做的一件事情就是加密(如果你希望该文档加密),要达到这个目的,你可以使用下面的方法:
    public void setEncryption(boolean strength, String userPassword, String ownerPassword, int permissions);
    • strength 是下面两个常量之一: 
    • PdfWriter.STRENGTH40BITS: 40 位 
    • PdfWriter.STRENGTH128BITS: 128位 (Acrobat Reader 5.0及以上版本支持) 
    • UserPassword和ownerPassword 可以为空或零长度,这种情况下, ownerPassword 将被随机的字符串代替 
    • Permissions 为下列常量之一: 
    • PdfWriter.AllowPrinting 
    • PdfWriter.AllowModifyContents 
    • PdfWriter.AllowCopy 
    • PdfWriter.AllowModifyAnnotations 
    • PdfWriter.AllowFillIn 
    • PdfWriter.AllowScreenReaders 
    • PdfWriter.AllowAssembly 
    • PdfWriter.AllowDegradedPrinting writer.setEncryption(PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowCopy);
    打开而无须密码,但用户不能打印、修改本文档。
    writer.setEncryption(PdfWriter.STRENGTH128BITS, "userpass", "ownerpass", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);将要求输入密码('userpass'),因为添加了AllowPrinting参数,你可以打印该文档而不会发生任何问题。