From the perspective of Aspose, my application does two things…
-
Convert Word file to HTML
Aspose.Words.Document docWord = new Aspose.Words.Document(wordFile);
docWord.Save(htmlFile);
-
Convert Word file to secure PDF file
Aspose.Words.Document doc = new Aspose.Words.Document(WordFile);
PdfSaveOptions saveOptions = new PdfSaveOptions();
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, “mypassword”, PdfEncryptionAlgorithm.RC4_128);
saveOptions.EncryptionDetails = encryptionDetails;
doc.Save(pdfAttachmentFileName, saveOptions);
This works fine but I need to be able to set the PDF security to allow printing. Can I do this with just Aspose.Words?
@devmanager,
Thanks for your inquiry. Yes, you can achieve your requirement using only Aspose.Words. Please check the following code example. Hope this helps you.
Document doc = new Document(MyDir + "Rendering.doc");
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, "password", PdfEncryptionAlgorithm.RC4_128);
// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;
// Extend permissions to allow printing
encryptionDetails.Permissions = PdfPermissions.Printing;
//Use multiple PdfPermissions as shown below
//encryptionDetails.Permissions = PdfPermissions.Printing | PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;
saveOptions.EncryptionDetails = encryptionDetails;
// Render the document to PDF format with the specified permissions.
doc.Save(MyDir + "Rendering.SpecifyPermissions Out.pdf", saveOptions);
A post was split to a new topic: Support of AES256 encryption