PXCp_CheckPassword Function Usage

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

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

DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

PXCp_CheckPassword Function Usage

Post by DolphinMann »

I seem to be having some trouble using the PXCp_CheckPassword function.

I found some sample pages: https://help.pdf-xchange.com/DEV/de ... ckpassword

but everything I try to use the function it returns an error code indicating incorrect password. Even if I take a brand new PDF, and using the X-Change Viewer add a password to open such as "123456", I can then open it in X-Change viewer by typing that password, but I cannot open it via code by sending that password into the above function.

I'm sure it has something to do with my point conversion since I am using C#, but I can't tell what it is. The pointer seems correct to me when I debug and print/display.

"password" comes in as a string
PDFObject is a valid pointer to the PDF object

Code: Select all

                        byte[] bytePassword = System.Text.UnicodeEncoding.Unicode.GetBytes(password);
                        int passwordLength = bytePassword.Length;
                        fixed (byte* passPointer = bytePassword)
                        {
                            this.result = XCPro35_Defs.PXCp_CheckPassword(this.pdfObject, ref *passPointer, passwordLength);
                        }
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: PXCp_CheckPassword Function Usage

Post by Ivan - Tracker Software »

For password "123456" you have to pass pointer to array of bytes with 6 bytes long:

Code: Select all

bytePassword[0] = 0x31;
bytePassword[1] = 0x32;
bytePassword[2] = 0x33;
bytePassword[3] = 0x34;
bytePassword[4] = 0x35;
bytePassword[5] = 0x36;
In your sample you will got at least 12 bytes (maybe 14 - I'm not so familiar with C#):

Code: Select all

bytePassword[0] = 0x31;
bytePassword[1] = 0x00;
bytePassword[2] = 0x32;
bytePassword[3] = 0x00;
bytePassword[4] = 0x33;
bytePassword[5] = 0x00;
bytePassword[6] = 0x34;
bytePassword[7] = 0x00;
bytePassword[8] = 0x35;
bytePassword[9] = 0x00;
bytePassword[10] = 0x36;
bytePassword[11] = 0x00;
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: PXCp_CheckPassword Function Usage

Post by DolphinMann »

You are correct, my byte array ended up being 14 I think. I will play around with your suggestion.

Thank you.
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: PXCp_CheckPassword Function Usage

Post by DolphinMann »

That worked.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK

Re: PXCp_CheckPassword Function Usage

Post by Will - Tracker Supp »

:D
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

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com