翻譯|使用教程|編輯:李顯亮|2020-09-28 10:24:55.190|閱讀 389 次
概述:在本文中,將學習如何使用C ++加密PDF文件。此外,本文還介紹了如何使用C ++設置不同的特權和解密受密碼保護的PDF文件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
PDF加密是使用密碼以及某些加密算法(包括AES或RC4)來保護文檔的過程。您還可以設置不同的特權,以限制用戶對不同操作的訪問。例如,您只能允許打印,添加注釋,填寫表格等。
在本文中,您將學習如何使用C ++加密PDF文件。此外,本文還介紹了如何使用C ++設置不同的特權和解密受密碼保護的PDF文件。
(安裝包僅提供部分功能,并設置限制,如需試用完整功能請)
以下是使用Aspose.PDF for C ++加密PDF文件的步驟。
以下代碼示例顯示了如何使用C ++加密PDF文件。
// Load an existing PDF document auto doc = MakeObject(L"..\\Data\\SecurityAndSignatures\\input.pdf"); // Way1: Using predefined privilege directly. System::SharedPtrprivilege = Aspose::Pdf::Facades::DocumentPrivilege::get_Print(); doc->Encrypt(L"user", L"owner", privilege, CryptoAlgorithm::AESx128, false); doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay1_out.pdf"); // Way2: Based on a predefined privilege and change some specifical permissions. System::SharedPtrprivilege2 = Aspose::Pdf::Facades::DocumentPrivilege::get_AllowAll(); privilege->set_AllowPrint(false); privilege->set_AllowModifyContents(false); doc->Encrypt(L"user", L"owner", privilege2, CryptoAlgorithm::AESx128, false); doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay2_out.pdf"); // Way3: Based on a predefined privilege and change some specifical Adobe Professional permissions combination. System::SharedPtrprivilege3 = Aspose::Pdf::Facades::DocumentPrivilege::get_ForbidAll(); privilege->set_ChangeAllowLevel(1); privilege->set_PrintAllowLevel(2); doc->Encrypt(L"user", L"owner", privilege3, CryptoAlgorithm::AESx128, false); doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay3_out.pdf"); // Way4: Mixes the way2 and way3 System::SharedPtrprivilege4 = Aspose::Pdf::Facades::DocumentPrivilege::get_ForbidAll(); privilege->set_ChangeAllowLevel(1); privilege->set_AllowPrint(true); doc->Encrypt(L"user", L"owner", privilege4, CryptoAlgorithm::AESx128, false); doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay4_out.pdf");
以下是使用Aspose.PDF for C ++解密PDF文件的步驟。
以下代碼示例顯示了如何使用C ++解密PDF。
// Load an existing PDF document auto doc = MakeObject(L"..\\Data\\SecurityAndSignatures\\Decrypt.pdf", L"password"); // Decrypt PDF doc->Decrypt(); // Save the updated document doc->Save(L"..\\Data\\SecurityAndSignatures\\Decrypt_out.pdf");
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn