How to identify pdf is password protected?

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
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

How to identify pdf is password protected?

Post by vivekpatel »

Hello,

How to identify the pdf file is password protected? any property for that?
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: How to identify pdf is password protected?

Post by Will - Tracker Supp »

Hi Vivek,

Thanks for the post - You have posted in the End User Editor forum. Are you looking to do this programmatically via the SDK, or did you mean to post in the End User forums?

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

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: How to identify pdf is password protected?

Post by vivekpatel »

Hello,

yes, pragmatically with SDK.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: How to identify pdf is password protected?

Post by Will - Tracker Supp »

Hi Vivek,

I've moved your post to the appropriate forum and will forward this on for further comment.

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

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to identify pdf is password protected?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

Please provide a better explanation for such a questions so that we can advice further.
1) Is the document already opened or is it a file on disk that you want to open?
2) What do you need this for exactly?
3) Do you need to check whether the password itself is present or just check some security permissions?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: How to identify pdf is password protected?

Post by vivekpatel »

Hello,

I have password protected file, i open this file in pdf tracker and it shows passsword window.
How to detect file is password protected or not before open to edit?
i want to check this programmatically in vb.net.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to identify pdf is password protected?

Post by Sasha - Tracker Dev Team »

This code should help:

Code: Select all

public class AuthCallback : PDFXEdit.IPXC_DocAuthCallback
{
	public void AuthDoc(PDFXEdit.IPXC_Document pDoc, uint nFlags)
	{
		//If this method is called then the document is protected
	}
}

private void checkForPasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
	AuthCallback clbk = new AuthCallback();
	pxcInst.OpenDocumentFromFile(@"D:\Test.pdf", clbk);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: How to identify pdf is password protected?

Post by vivekpatel »

Hello,
It is possible to identify that the document is password protected using "PDF Core Enumerations " ---> https://sdkhelp.pdf-xchange.com/vie ... umerations
Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to identify pdf is password protected?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

No, that is not possible. For the solution, check my previous reply.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: How to identify pdf is password protected?

Post by vivekpatel »

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to identify pdf is password protected?

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: How to identify pdf is password protected?

Post by prasantha »

Sasha - Tracker Dev Team wrote: Thu Oct 20, 2016 2:33 pm This code should help:

Code: Select all

public class AuthCallback : PDFXEdit.IPXC_DocAuthCallback
{
	public void AuthDoc(PDFXEdit.IPXC_Document pDoc, uint nFlags)
	{
		//If this method is called then the document is protected
	}
}

private void checkForPasswordToolStripMenuItem_Click(object sender, EventArgs e)
{
	AuthCallback clbk = new AuthCallback();
	pxcInst.OpenDocumentFromFile(@"D:\Test.pdf", clbk);
}
Cheers,
Alex
HI,
I am developing application using c# and I cant find respective method in c#. So could you let me know how can i do this check in c#?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17910
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to identify pdf is password protected?

Post by Tracker Supp-Stefan »

Hello prasantha,

Are you using the Viewer or Editor SDK?
The above discussed methods are from the Editor SDK - and they should be available irrespective of the programming language you use.
You might need to modify the above code to implement it in your own project, but that should be pretty straight forward for the above discussed methods.

Kind regards,
Stefan
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: How to identify pdf is password protected?

Post by prasantha »

Thank you for your response.
I am refering to the editor SDK. But I cant see the respetive method in c#.
Below are the available methods related to open file.
image.png
So i cant see a method to pass a callhback function or return value.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17910
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How to identify pdf is password protected?

Post by Tracker Supp-Stefan »

Hello prasantha,

Ahh - I thought you are having problems with the IPXC_DocAuthCallback

The posts above yours are 5+ years old - so it seems like OpenDocFromFile has been changed to OpenDocFromPath. Please use the open from path method instead and all should be well:
https://sdkhelp.pdf-xchange.com/vi ... ocFromPath

Kind regards,
Stefan
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: How to identify pdf is password protected?

Post by prasantha »

So using above method, I cant check whether the documetn is password protected or not. Is there any other open method which return whether the document is password protected or not? Becuase currently I have used seperate methods to check whether the documetn is password protected and then another method to open the file. it hurts the performance of the large file opening. So i m looking for a method that both check and open can be done in a single call.
zarkogajic
User
Posts: 1372
Joined: Thu Sep 05, 2019 12:35 pm

Re: How to identify pdf is password protected?

Post by zarkogajic »

Hi,

Do you need to open a document as PXC or PXV document?

You can use op.openDoc with "NoAuth = true" to get the PXCDocument. If that operation throws an exception and if the exception is "HResult($FFFFFFFF82141008)" - the document is password protected.

p.s.
unchecked((int)0x82141008)

-žarko
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8588
Joined: Wed Jan 03, 2018 6:52 pm

How to identify pdf is password protected?

Post by TrackerSupp-Daniel »

:)
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Post Reply