HTML
JPG
PDF
XML
PDF
PDF
透過 C++ 加密 PDF 文件
將 Excel 電子表格轉換為 PDF 文件,並使用 Aspose.Cells C++ 庫對其進行密碼保護。
如何使用 C++ 加密 PDF 文件
為了加密 PDF 文件,我們將使用
API這是一個功能豐富、功能強大且易於使用的文件加密API for C++平台。您可以直接下載最新版本,打開即可
套件管理器,搜尋 Aspose.Cells.Cpp 並安裝。您也可以從套件管理器控制台使用以下命令。
Aspose.Cells
PM> Install-Package Aspose.Cells.Cpp
透過 C++ 加密 PDF 檔案的步驟
只需幾行程式碼即可使用 Aspose.Cells API 進行文件保護。
- 使用 Workbook 類別載入或建立新的 Excel 文件
- 使用 PdfSecurityOptions 類別設定安全選項
- 透過Save()方法保存加密後的PDF文件
系統需求
Aspose.Cells for C++ 支援所有主要平台和作業系統。請確保您具備以下先決條件。
- Microsoft Windows 或具有 C++ 運行時環境的相容作業系統,適用於 Windows 32 位元、Windows 64 位元和 Linux 64 位元。
- 在專案中加入對 Aspose.Cells for C++ DLL 的引用。
命令
Aspose::Cells::Startup();
//load/creat the Excel file
Workbook wb;
//Set cell value
wb.GetWorksheets().Get(0).GetCells().Get(u"A1").PutValue(u"test");
//Set security options using PdfSecurityOptions class
PdfSecurityOptions securityOptions;
securityOptions.SetOwnerPassword(u"123");
securityOptions.SetPrintPermission(true);
securityOptions.SetAccessibilityExtractContent(true);
//Set saving PDF parameters
PdfSaveOptions pdfSaveOptions;
pdfSaveOptions.SetSecurityOptions(securityOptions);
//Save encrypted PDF files
wb.Save("security.pdf", pdfSaveOptions);
Aspose::Cells::Cleanup();