I am working in VB.NET to secure a PDF using PDF-XChange SDK.
I found a reference in your forum here: (link included):
viewtopic.php?p=162918&hilit=password#p162918
The example in that post uses:
Code: Select all
IPXC_SecurityPolicy secPolicy = secHandler.CreateNewPolicy(IPXV_Inst.GetDlgParentWindow(null));This line automatically opens a password/security dialog window.
In my implementation, I do not want any UI prompts.
Instead, I need to:
✔ Set the user password
✔ Set the owner password
✔ Configure permissions (printing/copy/etc.)
✔ Apply security entirely in code, silently
May I please get an example of:
Creating IPXC_SecurityPolicy fully programmatically
Setting password values and permissions directly
What the IStream represents in this context (in-memory or file-backed data?)
A VB.NET code snippet following your recommended API approach
Below is the snippet from your forum that I am taking a reference from:
Code: Select all
secMethod = IPXS_Inst.StrToAtom("Standard");
IPXC_SecurityHandler secHandler = IPXC_Inst.GetSecurityHandler(secMethod);
// >> once do the following code
IStream streamWithSerializedSecPolicy; // create IStream-object to fill it below
...
IPXC_SecurityPolicy secPolicy = secHandler.CreateNewPolicy(IPXV_Inst.GetDlgParentWindow(null)); // it shows dlg to fill all sec-options
if (secPolicy != null)
secPolicy.Store(streamWithSerializedSecPolicy);
// <<
...
IPXC_SecurityPolicy secPolicy = secHandler.LoadPolicy(streamWithSerializedSecPolicy);
op = IPXV_Inst.CreateOp(IPXV_Inst.Str2ID("op.document.setSecurity"));
op.Params["Input"].Add().v = doc;
op.Params["Options.Handler"] = "Standard";
op.Params["Options.Data"] = secPolicy;
op.Do();
Thank you!
Best Regards,
Anushka