تأمين وثائق PDF
Contents
[
Hide
]
في بعض الأحيان ، يحتاج المطورون إلى العمل مع ملفات PDF المشفرة. على سبيل المثال ، يحتاجون إلى تأمين المستندات بكلمات مرور المستخدم والمالك بحيث لا يمكن لأي شخص فتحها فقط ، أو يريدون تقييد ما إذا كان يمكن طباعة محتوى المستند أو استخراجه.
تشرح هذه المقالة كيفية تمرير خيارات الأمان PDF عند حفظ جداول البيانات في PDF.
توفر واجهات برمجة التطبيقات Aspose.Cells امتدادخيارات PdfSecurityفئة للعمل بأمان تنسيق ملف PDF. يصف نموذج التعليمات البرمجية أدناه كيفية إنشاء ملفات PDF آمنة باستخدام Aspose.Cells for Java API.
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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SecurePDFDocuments.class); | |
// Open an Excel file | |
Workbook workbook = new Workbook(dataDir + "input.xlsx"); | |
// Instantiate PDFSaveOptions to manage security attributes | |
PdfSaveOptions saveOption = new PdfSaveOptions(); | |
saveOption.setSecurityOptions(new PdfSecurityOptions()); | |
// Set the user password | |
saveOption.getSecurityOptions().setUserPassword("user"); | |
// Set the owner password | |
saveOption.getSecurityOptions().setOwnerPassword("owner"); | |
// Disable extracting content permission | |
saveOption.getSecurityOptions().setExtractContentPermission(false); | |
// Disable print permission | |
saveOption.getSecurityOptions().setPrintPermission(false); | |
// Save the PDF document with encrypted settings | |
workbook.save(dataDir + "securepdf_test.pdf", saveOption); |
إذا كان جدول البيانات يحتوي على صيغ ، فمن الأفضل الاتصالWorkbook.calculateFormula () قبل تحويله إلى PDF. هذا يضمن إعادة حساب القيم التابعة للصيغة ، وتقديم القيم الصحيحة في PDF.