We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

FillField and Set Multiple Privileges

I want to fill some fields in a PDF template and then set multiple security privileges to a document. However, it seems only the last privilege call takes effect when I view the document properties through Adobe Acrobat Pro. Is the following example the correct way to achieve these settings (I’m looking to allow Print and Form Fill with just an admin password)?


Dim template = New System.IO.FileStream(“pdf_form.pdf”, System.IO.FileMode.Open)
Dim formFilled = New System.IO.FileStream(“pdf_form_filled.pdf”, System.IO.FileMode.Create)
Dim f = New Aspose.Pdf.Kit.Form(template, formFilled)
f.FillField(“FieldName”, “MyName”)
f.FillField(“FieldEmail”, "my@email.com")
f.Save()

Dim s = New PdfFileSecurity(formFilled, formFilled)
s.SetPrivilege(DocumentPrivilege.ForbidAll)
s.SetPrivilege(DocumentPrivilege.Print) ’ If reverse this line and the next line, I get the Print permission allowed
s.SetPrivilege(DocumentPrivilege.FillIn) ’ With this line last, only form fill is allowed
s.ChangePassword("", “”, “owner”)
formFilled.Close()

Nevermind, I was able to find this in the documentation and fix it using the instance properties of DocumentPrivilege.


For anyone else wondering, use it like so:

Dim s = New PdfFileSecurity(formFilled, formFilled)
Dim dp = DocumentPrivilege.ForbidAll
dp.AllowPrint = True
dp.AllowFillIn = True

s.SetPrivilege(dp)

Hi Phil,

You’re right; the way you used in your second post in the correct way to set multiple privileges at the same time. I’m glad to know that it worked at your end. If you find any further questions or need assistance, please do let us know.

Regards,