如何检查pdf文件是否受密码保护 [英] how to check pdf file is password protected i
本文介绍了如何检查pdf文件是否受密码保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Java中检查pdf文件是否受密码保护. 我知道几个可以做到这一点的工具/库,但我想知道仅使用Java中的程序是否可以做到这一点. 预先感谢..
How to check pdf file is password protected or not in java.. I know of several tools/libraries that can do this but I want to know if this is possible with just program in java. Thanks in advance..
推荐答案
您可以使用PDFBox:
you can use PDFBox:
代码示例:
try
{
document = PDDocument.load( yourPDFfile );
if( document.isEncrypted() )
{
//ITS ENCRYPTED!
}
}
使用Maven吗?
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0</version>
</dependency>
这篇关于如何检查pdf文件是否受密码保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文