如何使pdf在itext中只读 [英] How to make pdf read only in itext

查看:235
本文介绍了如何使pdf在itext中只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码遵循

public static void main(String[] args) {
        try 
        {
            PdfReader reader = new PdfReader("D:\\SF_Users.pdf");
            int n = reader.getNumberOfPages();
            Rectangle psize = reader.getPageSize(1);
            Document document = new Document(psize);
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream("D:\\new.pdf"));
            document.open();
            PdfContentByte pdf = writer.getDirectContent();
            document.newPage();
            PdfImportedPage page = writer.getImportedPage(reader, 1);
            pdf.addTemplate(page, .5f, 0, 0, .5f, 60, 120);
            document.close();
        } catch (Exception de) {
        }
    }

在这里,我可以写pdf的同时阅读

Here i can able to read pdf while writting i want make it read only

谢谢

推荐答案

您是否尝试过使用PdfEncryptionSettings API?

Have you tried using the PdfEncryptionSettings API?

文档的打开权限可以是AllowPrinting,AllowModifyContents,AllowCopy,AllowModifyAnnotations,AllowFillIn,AllowScreenReaders,AllowAssembly和AllowDegradedPrinting.

The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.

这篇关于如何使pdf在itext中只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆