Pdf文件操作相关问题

1)我想删除或禁用一个pdf文件中的所有超级链接是否可以,有什么办法吗?
2)这个pdf我想设置成只读模式(不能复制,修改,打印,除了浏览没有任何权限,但不要密码)是否可以,有什么办法吗?
附件中为我的pdf测试文件
Google-Java编程风格指南中文版.zip (878.3 KB)

@wdacat

感谢您与支持人员联系。

我们担心不能禁用或删除PDF文档中的超链接。 但是,我们设计了一种解决方法,通过设置权限而无需密码保护,将超链接定向到同一页面并保护PDF。 请尝试在您的环境中使用以下代码段,然后与我们分享您的反馈。

    // Load the PDF file
    Document doc = new Document(dataDir + "Google-Java¦a¦¦+t+±++--+-+-¦µ.pdf");

    // Get the link annotation from pages of document
    for (Page page : doc.getPages())
    {
        for (Iterator<Annotation> it = page.getAnnotations().iterator(); it.hasNext();) 
        {
            LinkAnnotation linkAnnot = (LinkAnnotation) it.next();
            linkAnnot.setAction(new GoToAction(page));
        }
    }
    // Forbid all privileges on the document
    DocumentPrivilege privilege = DocumentPrivilege.getForbidAll();

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

    // Save the document with updated link
    doc.save(dataDir + "Test.pdf");

已附上生成的PDF文档供您参考。Test.pdf 我们希望这会有所帮助。 如果您需要任何进一步的帮助,请随时与我们联系。