简体   繁体   中英

Editable to Non-Editable pdf using Aspose PDF

在使用Aspose PDF向其添加一些文本后,如何将可编辑的pdf保存为不可编辑?

After adding some text to a PDF file, you can set Document Privileges by using the code snippet below:

    //Open source document
    Document document = new Document(inputFile);        

    //Forbid all privileges on the document
    DocumentPrivilege privilege = DocumentPrivilege.getForbidAll();

    //Set the desired privileges
    PdfFileSecurity fileSecurity = new PdfFileSecurity(document);
    fileSecurity.setPrivilege(privilege);

    //Save resulting PDF document
    document.save(outputFile);

This will forbid all document privileges and the PDF file would not be editable anymore. I hope this will be helpful. Please let us know if you need any further assistance.

I work with Aspose as Developer Evangelist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM