Free Support Forum - aspose.com

Saving Word to PDF with Security

I am trying to use APOSE.Words to save a word document to a PDF with some security. I am having trouble getting more than one permission to be transfered to the PDF. I did see a C# example where it looked like they were just concatenating the permissions together, but that is not working for me. I have tried setting them seperatly and concatinating them and the last Permission seems to be the only one that works. Can you let me know what I am doing wrong? Here is my code:

Dim doc as New Document("C:\AsposeText.docx")
Dim pdfsaveoptions As New Aspose.Words.Saving.PdfSaveOptions
Dim encryptDetails As New Aspose.Words.Saving.PdfEncryptionDetails("", "owner", Saving.PdfEncryptionAlgorithm.RC4_128)

'encryptDetails.Permissions = Saving.PdfPermissions.Printing
'encryptDetails.Permissions = Saving.PdfPermissions.ContentCopyForAccessibility

encryptDetails.Permissions = Saving.PdfPermissions.ContentCopyForAccessibility & Saving.PdfPermissions.Printing

pdfsaveoptions.EncryptionDetails = encryptDetails

doc.Save("C:\testword\AsposeTest.pdf", pdfsaveoptions)

Thanks

Hi

Thanks for your request. You can specify multiple options as shown below:

Document doc = new Document(@"Test001\in.doc");

PdfSaveOptions opt = new PdfSaveOptions();

opt.EncryptionDetails = new PdfEncryptionDetails("", "test", PdfEncryptionAlgorithm.RC4_128);

opt.EncryptionDetails.Permissions = PdfPermissions.DisallowAll | PdfPermissions.Printing;

doc.Save(@"Test001\out.pdf", opt);

best regards,

I had already seen this example which got me as far as I was.

I did figure my problem out however. I was mistakingly converting the | to and AND instead of an OR in visual basic. Everything is working correctly now.

Thanks for the help

Hi

Thank you for additional information. It is perfect that you managed to achieve what you need.

Best regards,