How to check owner password using PXCp_CheckPassword

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

docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

How to check owner password using PXCp_CheckPassword

Post by docu-track99 »

Hi,

I'm having problem using PXCp_CheckPassword function in VB.NET. Every time i use the function it returns a long numeric value. Sample code from your website https://help.pdf-xchange.com/DEV/de ... ckpassword says that return value should be 1 (for user password) or 2 (for owner password).

I attached a sample code and a pdf. The pdf password is "password".

Any help is appreciated.
You do not have the required permissions to view the files attached to this post.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: How to check owner password using PXCp_CheckPassword

Post by Ivan - Tracker Software »

The problem is with how you declare and use PXCp_CheckPassword function.
Correct declaration for VB.NET is:

Code: Select all

<DllImport("xcpro40")> Public Shared Function PXCp_CheckPassword(ByVal pObject As Integer, <MarshalAs(UnmanagedType.LPStr)> ByVal pPassword As String, ByVal PassLen As Integer) As Integer
End Function
Please note, there is also Unicode version of that function

Code: Select all

<DllImport("xcpro40")> Public Shared Function PXCp_CheckPasswordW(ByVal pObject As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal pPassword As String, ByVal PassLen As Integer) As Integer
End Function
Now, your CheckPassword will be a bit more simple:

Code: Select all

    Public Function CheckPDFPassword(ByVal sPassword As String) As Integer
		Dim pass_len As Integer
		pass_len = Len(sPassword)
		CheckPDFPassword = XCPro40_Defs.PXCp_CheckPassword(nSelectedDocument, sPassword, pass_len)
    End Function
HTH
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.
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: How to check owner password using PXCp_CheckPassword

Post by docu-track99 »

That works. Thank you.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: How to check owner password using PXCp_CheckPassword

Post by Tracker Supp-Stefan »

:)