how to Save a pdf copy with a password

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

how to Save a pdf copy with a password

Post by prasantha »

I have a requirment to save a new copy of the opened document with a password.
I can save the document using Doc.Save() method. But I could not find a way how to add password there.
Can anyone let me know how to add a password while saving a copy of the documennt

Thank you
Prasantha
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: how to Save a pdf copy with a password

Post by Vasyl-Tracker Dev Team »

Hi Prasantha.

You need to setup password-security for the doc, before saving it:

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();

...
// then save the secured doc to apply just installed passw-security 
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply