تأمين وثائق PDF
Contents
[
Hide
]
في بعض الأحيان ، يحتاج المطورون إلى العمل مع ملفات PDF المشفرة. على سبيل المثال ، يحتاجون إلى تأمين المستندات بكلمات مرور المستخدم والمالك بحيث لا يمكن لأي شخص فتحها فقط ، أو يريدون تقييد ما إذا كان يمكن طباعة محتوى المستند أو استخراجه.
تشرح هذه المقالة كيفية تمرير خيارات الأمان PDF عند حفظ جداول البيانات في PDF.
يوفر Aspose.Cells ملفAspose.Cells.Rendering.PdfSecurity مساحة للعمل مع الأمان. يصف نموذج التعليمات البرمجية أدناه كيفية تأمين ملفات PDF باستخدام Aspose.Cells.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Open an Excel file | |
Workbook workbook = new Workbook(dataDir+ "input.xlsx"); | |
// Instantiate PDFSaveOptions to manage security attributes | |
PdfSaveOptions saveOption = new PdfSaveOptions(); | |
saveOption.SecurityOptions = new Aspose.Cells.Rendering.PdfSecurity.PdfSecurityOptions(); | |
// Set the user password | |
saveOption.SecurityOptions.UserPassword = "user"; | |
// Set the owner password | |
saveOption.SecurityOptions.OwnerPassword = "owner"; | |
// Disable extracting content permission | |
saveOption.SecurityOptions.ExtractContentPermission = false; | |
// Disable print permission | |
saveOption.SecurityOptions.PrintPermission = false; | |
// Save the PDF document with encrypted settings | |
workbook.Save(dataDir+ "securepdf_test.out.pdf", saveOption); |
إذا كان جدول البيانات يحتوي على صيغ ، فمن الأفضل الاتصالالمصنف .CalculateFormula ()قبل تحويله إلى PDF. هذا يضمن إعادة حساب القيم التابعة للصيغة وتقديم القيم الصحيحة في PDF.