remove encryption from pdf with pdfbox, like qpdf

倾然丶 夕夏残阳落幕 提交于 2019-11-30 19:46:19

This is what you'd need to do. Inspired from the PDFBox WriteDecodedDoc tool. You may have to include the bouncycastle jar (http://www.bouncycastle.org/latest_releases.html)

    if (doc.isEncrypted()) {
        try {
            doc.decrypt("");
            doc.setAllSecurityToBeRemoved(true);
        }
        catch (Exception e) {
            throw new Exception("The document is encrypted, and we can't decrypt it.", e);
        }
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!