Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Detecting Invalid Password? |
Post Reply |
Author | |
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Posted: 23 Jul 12 at 7:54AM |
LoadFromFile should return "2" if the password is incorrect in QPL 7.26. This used to be quite reliable in 7.xx and this logic was moved to QPL 8.xx where it now returns a 0 and LastErrorCode is set to 404 - InvalidPassword.
Does the PDF file have a User and Master password ? It could also depend on the PDF file itself. If the file has a blank user password but has a master password then the file will still open correctly with QP.SetAdvancePassword(''); - It could be that the renderer is having a problem rendering the file. Where does the Exception happen and what is the exception reporting ? If you send me the PDF I will see if I can reproduce the Exception in QPL 8.xx. There have been many bugs and enhancements added to QPL 8.xx compared to 7.26. Andrew. |
|
ExchangeViews
Team Player Joined: 13 Mar 12 Status: Offline Points: 38 |
Post Options
Thanks(0)
|
V8.x does not use SetAdvancePassword(). You need to directly use loadfromfile('test.pdf', password);
Upgraded version return correct value for invalid password. You can try the trial version. |
|
Wheeley
Senior Member Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
Post Options
Thanks(0)
|
Straight from the upgrade to 8 technical guide:
The LoadFrom* functions now return 1 on success and 0 on failure. In QPL v7 these functions would return 2 if an encrypted document made use of object streams or cross reference streams. This is no longer necessary as these functions have a new password parameter. If the wrong password is given, the LoadFrom* functions will return 0 and the LastErrorCode function will return error code 404. Wheeley |
|
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
|
I have no problem upgrading but are you saying 8.x will work differently than 7.26 as far as what I described?
Can you tell me what will be different in 8.x that would allow me to have a controlled test to see if the password is invalid? Does RenderPageToStream() return somethig different? Does LoadFromFile() return something different?
|
|
ExchangeViews
Team Player Joined: 13 Mar 12 Status: Offline Points: 38 |
Post Options
Thanks(0)
|
Use QuickPDF 8.xx.
|
|
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
|
I am using Delphi 7 and QuickPDF 7.26.
I have a program that allows the user to select a PDF file from disk and it gives them the option to input a password in case the PDF is secured. My program then calls SetAdvancePassword(), then LoadFromFile(). Then it loops for each page calling RenderPageToStream(). I then display the rendered image so the user can view each page. All of this code works fine if...The PDF is not secured or the PDF is secured and the user has supplied the correct password. But if the PDF is secured and the user supplies an incorrect password, I can't seem to figure out how to "detect" that. The LoadFromFile() method works and returns a 1. The RenderPageToStream() also returns a 1 and the LastRenderError is blank. So I have no way to detect it actually fails. The result is the rendered image is just a blank white image. The odd thing is when I run my program from the Delphi IDE, the call to RenderPageToStream() actually throws an exception message that shows up in the Delphi IDE but the QuickPDF library must be trapping that exception because I do not get an exception in my code. So once again I cant seem to figure out how to detect an invalid password. Any help would be much appriciated. Wayne |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store