PDF 文檔保護解決方案

使用免費的跨平台應用程序和 API 保護 PDF 文檔

如何使用.PDF庫保護 PDF 檔

為了保護PDF文件,我們將使用[Aspose.PDF](https://products.aspose.com/pdf)API,這是一個功能豐富,功能強大且易於使用的文檔操作API,適用於 平臺。打開 [NuGet](https://www.nuget.org/packages/aspose.pdf) 包管理器,搜索“.PDF”並安裝。您也可以從程式包管理器主控台使用以下命令。您可以使用 [文件](https://reference.aspose.com/pdf/net/aspose.pdf/document) 物件的 [加密](https://reference.aspose.com/pdf/net/aspose.pdf.document/encrypt/methods/1) 方法來加密 PDF 檔。您可以將使用者密碼、擁有者密碼和許可權傳遞給 Encrypt 方法。除此之外,您還可以傳遞 [加密演算法](https://reference.aspose.com/pdf/net/aspose.pdf/cryptoalgorithm) 枚舉的任何值。此枚舉提供加密演演算法和金鑰大小的不同組合。您可以傳遞您選擇的值。最後,使用文件物件的 [保存](https://reference.aspose.com/pdf/net/aspose.pdf.document/save/methods/4) 方法保存加密的 PDF 檔。

用於在文檔中添加或刪除電子簽名的高代碼 API


本機 API,用於使用 .NET、.NET Core、Java C++和安卓對 PDF 文件進行電子簽名。

加密檔

<% protect0.code-block.subtitle %>

// Open document
Document document = new Document(dataDir+ "Encrypt.pdf");
// Encrypt PDF
document.Encrypt("user", "owner", 0, CryptoAlgorithm.RC4x128);
dataDir = dataDir + "Encrypt_out.pdf";
// Save updated PDF
document.Save(dataDir);