打开未使用密码加密的文档

问题描述 投票:0回答:1

我试图用密码将不安全的PDF文件打开。我很惊讶它没有出现异常就打开了。所以我的问题是,编写此类代码是否有任何风险副作用,我的意思是使用任何密码打开未加密的PDF吗?谢谢

aspose aspose.pdf
1个回答
0
投票

@@ Khalil,

使用密码打开这样的文件没有任何问题,因为构造函数仅在确定文件加密后才在内部使用密码。因此,为了更清楚起见,您可以将代码保持原样,或者更好地对其进行更新:

Document document = new Document(dataDir + "Aspose.pdf");
PdfFileInfo info = new PdfFileInfo(document);
if (info.IsPdfFile)
{
    if (info.IsEncrypted)
    {
        //Source PDF document is password protected
        //TODO Code Here
    }
    else
    {
        //Source PDF document is not password protected
        //TODO Code Here
    }
}

PS:我和Aspose一起担任开发人员推广人员。

© www.soinside.com 2019 - 2024. All rights reserved.