These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Setting security policy in NET.VB

lpacifico
Registered: May 19 2008
Posts: 9

Can somebody help me with applying pdf security inside of Visual Basic code? I learned that function encryptUsingPolicy() does that. The problem is that I know the policy NAME, but the function encryptUsingPolicy() accepts a policy NUMBER. How can I find the policy number by its name? (I 8.0 Professional)
My code is:

Dim gApp As Acrobat.CAcroApp = Nothing
Dim gAVDoc As Acrobat.CAcroAVDoc = Nothing
Dim gPDDoc As Acrobat.CAcroPDDoc = Nothing

If gApp Is Nothing Then
gApp = CreateObject("AcroExch.App")
End If

If gAVDoc Is Nothing Then
gAVDoc = CreateObject("AcroExch.AVDoc")
End If

gPDDoc = gAVDoc.GetPDDoc()
jso = gPDDoc.GetJSObject
‘???????????
jso.encryptUsingPolicy("test2")

Thank you
Lana

My Product Information:
Acrobat Pro 8.0, Windows
plevy
Expert
Registered: Jul 8 2008
Posts: 80
The ID looks like it needs to come from an element of security.getSecurityPolicies. There is an extra step or two to lookup the security policy id from the name. Get the security object from the document object, Get the filtered list of security policies using getSecurityPolicies, and then get the policy ID of the policy you want.

See in the Acrobar Java Scripting Reference, security object, SecurityPolicy object, and Document.encryptUsingPolicy.

These should guide you for what you need to do in VB.