How can I Remove Security?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

How can I Remove Security?

Post by Dorwol »

I see, there is a command for doing this...

Code: Select all

ctrl.DoDocumentVerb(docId, "", "RemoveSecurity", dataIn, NULL, PXCVA_NoUI);
// if success - save document without security
ctrl.SaveDocument(docId);
But where do I set the special owner password after opening the document for calling RemoveSecurity?

I your documentation, I read: "For example, if the document is the password-protected then you should specify the special *owner
password for opening."


*OpenDocument will only allow a "OpenPassword" but no way to set the "OwnerPassword".
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: How can I Remove Security?

Post by Stefan - PDF-XChange »

Hello Dorwol,

A PDF could have two passwords - a user and owner one. It could be that the PDF has an empty user password and an arbitrary owner one - if you open the file with empty password in this case you won't be able to change (remove) the security restrictions, and if you open it with the owner password - the RemoveSecurity will work.

Best,
Stefan
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I Remove Security?

Post by Dorwol »

NO WAY :(

1. Document has NO user-PW
2. Dokument has a Owner-PW ("test")

Please try it...

Code: Select all

sMyOwnerPW = "test"
Viewer.OpenDocument sFileName, sMyOwnerPW, 0, PXCVA_NoUI    ' Are you sure, that OpenPW = OwnerPW if UserPW is empty!?
Viewer.DoDocumentVerb 0, "", "RemoveSecurity", DataIn, Null, PXCVA_NoUI
Viewer.SaveDocument 0, sNewFileName, PXCVA_DocumentSaveCopyAs, PXCVA_Sync Or PXCVA_NoUI
Result is still a protected document! :|

So please, what do I wrong?
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: How can I Remove Security?

Post by John - Tracker Supp »

Please send an example file (zipped) thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I Remove Security?

Post by Dorwol »

??? example file ??? :?

I'm not sure what do you mean because the complete code I have already posted.

But OK, please see the attached example-code (exactly the same...!)
You do not have the required permissions to view the files attached to this post.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: How can I Remove Security?

Post by John - Tracker Supp »

Dorwol,

If you want prompt answers - we do need all information and samples - otherwise our team have to spend valuable time potentially recreating a sample PDF and application to provide an answer - if you are happy to wait until someone has the time to do all this - just let us know and we will place it into the queue that things go when where we cannot quickly test and get to the bottom of it - the choice is yours.

Time is at an absolute premium here at the moment preparing new releases and products - the staff that answer these questions have to be interrupted from doing their primary job to do so - and we try and minimise the 'down time' by ensuring we have as complete a set of info as we can - so you can an expedited answer and they can test and answer quickly.

Please understand we ask such annoying questions for good reason - not to simply irritate you ...
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I Remove Security?

Post by Dorwol »

John - Tracker Supp wrote:Dorwol,

If you want prompt answers - we do need all information and samples - otherwise our team have to spend valuable time potentially recreating a sample PDF and application to provide an answer - if you are happy to wait until someone has the time to do all this - just let us know and we will place it into the queue that things go when where we cannot quickly test and get to the bottom of it - the choice is yours.

Time is at an absolute premium here at the moment preparing new releases and products - the staff that answer these questions have to be interrupted from doing their primary job to do so - and we try and minimise the 'down time' by ensuring we have as complete a set of info as we can - so you can an expedited answer and they can test and answer quickly.

Please understand we ask such annoying questions for good reason - not to simply irritate you ...
Sorry, but up to the present moment I was thinking, that there is no bug or prblem with the viewer - I was thinking there is only a code-mistake from me. I was not aware that you test the code yet to need. So please let me know, if you need further infos/code samples!
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: How can I Remove Security?

Post by John - Tracker Supp »

I am not saying there is or is not a bug - I am just saying that to ensure we can answer fully and quickly - we do need as much info to test and reproduce the problem - so then we can say - its your code or no - its our bug.

Thanks for your your understanding.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: How can I Remove Security?

Post by Vasyl - PDF-XChange »

Hi, Dorwol.

We have found one small but annoying bug with 'OpenDocument'. Current behavior is: if document is secured the viewer firstly will try to open it with empty password and if success - will ignore the non-empty 'owner' password passed from you. Sure - it is wrong behavior and we will fix it in the next build. Currently you may use next workaround:

Viewer.OpenDocument sFileName, "", 0, PXCVA_NoUI
Viewer.DoDocumentVerb 0, "", "RemoveSecurity", DataIn, Null, 0 // use it without PXCVA_NoUI ! it will ask the 'owner' password...
Viewer.SaveDocument 0, sNewFileName, PXCVA_DocumentSaveCopyAs, PXCVA_Sync Or PXCVA_NoUI

HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I Remove Security?

Post by Dorwol »

Vasyl-Tracker Dev Team wrote:Viewer.DoDocumentVerb 0, "", "RemoveSecurity", DataIn, Null, 0 // use it without PXCVA_NoUI ! it will ask the 'owner' password...
Thank you for Lightspeed answer. But the Owner PW is very secret and comes AES crypted from the database. I can not prompt a dialog for entry it. :mrgreen:

So I think I must wait for next build :|

What do you think, the next build will be released?

@Paul, Stefan: Thanks to you too for very fast help!
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: How can I Remove Security?

Post by Stefan - PDF-XChange »

Hi Dorwol,

When The Viewer prompts you for the password - you can capture the
Prompts.EnterDocumentPassword
Event pass the password from the database without any user interaction.

I do not have any specific date for the next build yet - but will let you know as soon as I do :)

Best,
Stefan
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I Remove Security?

Post by Dorwol »

> you can capture the Prompts.EnterDocumentPassword
But how? :?

Do you have a little sample-code for me please?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: How can I Remove Security?

Post by Stefan - PDF-XChange »

The below is with the C# syntax but I hope it's pretty clear:

Code: Select all

private void axCoPDFXCview1_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e)
{
    switch(e.type)
    {
    case (int)PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnDisplayPrompt:
        {
            if (e.name == "Prompts.EnterDocumentPassword")
            {
                object vDataIn = "test"; //Your document's Author password
                axCoPDFXCview1.SetProperty("Prompts.EnterDocumentPassword.Password", vDataIn, 0);
                axCoPDFXCview1.SetProperty("Prompts.EnterDocumentPassword.UserChoice", 1, 0);
            }
            break;
        }
    }            
}