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!
Problems with DecryptFile Function |
Post Reply |
Author | |
Shotgun Tom
Senior Member Joined: 14 Aug 09 Location: Phoenix, AZ Status: Offline Points: 53 |
Post Options
Thanks(0)
Posted: 19 Dec 09 at 8:13PM |
I have spent the last two days trying to implement a decrypt file routine using, primarily, the QuickPDF DecryptFile function.
The function looks like it works in that it returns a success code and actually writes the file... but there is no PDF reader on the planet that will open the file. I thought for sure it must something I was doing. I tried securing several different files... some with just a user password some with user and owner passwords... different levels of encryption. I set the security in Adobe Pro 9.2.
Then I tried using Debenu's QuickPDF Tools. Lo and behold, the same thing. It writes the file but I can't open it in any PDF Reader... not Adobe, Acrobat, Fox-It, PCX View... they all give the same error. The file is corrupted. I assume that Debenu is using the DecryptFile routine in 7.17 which is what I've been dealing with.
Anyone else run into this problem? Is this a known issue?
Tom
|
|
Michel_K17
Newbie www.exp-systems.com Joined: 25 Jan 03 Status: Offline Points: 297 |
Post Options
Thanks(0)
|
Actually, I have been using this function (successfully) for the last 4 years. Here is my VB code.
Note: make sure you use the "Owner" password. It will definitely not work with the "User" password. I hope it helps. '--------------------------------------------------------------------------------------- ' Procedure : PDF_Decrypt_File ' DateTime : 11/26/2005 10:41 ' Author : Michel_K17 ' Purpose : This function will take an encrypted/locked PDF, and save it unencrypted. '--------------------------------------------------------------------------------------- ' Private Function PDF_Decrypt_File(MyFile As String, pwd As String) As Boolean ' Trap Errors On Error GoTo Error_Handler ' Remove the Extension If Right$(MyFile, 4) = PDF Then MyFile = Left$(MyFile, Len(MyFile) - 4) ' Rename the file to process to an intermediate file Name MyFile & PDF As MyFile & "_D4W" & PDF ' Decrypt it rtn = oPDF.DecryptFile(MyFile & "_D4W" & PDF, MyFile & PDF, Decrypt(pwd, fUnicodeUser)) If rtn = 1 Then PDF_Decrypt_File = True ' Delete the intermediate file Kill MyFile & "_D4W" & PDF Exit Function Error_Handler: ' An unexpected error occured. Log it. (MUST have this line first, or the Err object gets reset). olog.LogError False, Err.Number, Err.Description, Err.LastDllError, "PDF_Decrypt_File" End Function |
|
Michel
|
|
Shotgun Tom
Senior Member Joined: 14 Aug 09 Location: Phoenix, AZ Status: Offline Points: 53 |
Post Options
Thanks(0)
|
Hi Michel:
Thank you for your reply. I will try this code.
However, many, many files are encrypted only with a User Password. In other words, there are no permission's encryption, just a password for the User. If I can't use the User password, how can I decrypt those successfully?
Tom
BTW, I'm talking about permanently decrypting... that is... re-saving the file with no passwords, no security. Edited by Shotgun Tom - 20 Dec 09 at 2:05AM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Tom!
We're talking about main and user passwords. The user password is the one you have to insert while opening the pdf in a reader. The main password the user won't see ... it's only to make the pdf-settings a little bit saver. It's not possible to set only a user password. If the creator of a pdf determines a user- and not a main password the user password will be the main password, too. There's no problem to analyze the structure of a pdf if there are user- and/or main-passwords. If you want to decrypt AND SAVE a pdf which has a main- and a user-password it's okay to insert only the main-password. If there's a user-password you can't do things like previews and textextractions without the user password... and i think that's good ;-) This behavior doesn't belong only to the QuickPDF-sdk... that's normal for all libraries. Cheers, Ingo BTW: To all readers and writers here... Merry Christmas and a Happy New Year 2010! |
|
Shotgun Tom
Senior Member Joined: 14 Aug 09 Location: Phoenix, AZ Status: Offline Points: 53 |
Post Options
Thanks(0)
|
Hi Ingo (and Michel):
Thank you for the reply, Ingo. Just to let you guy's know... I finally went to bed and slept for a few hours. Woke up and found out what I was doing wrong. It had to do with having the document open in a viewer in the same program I was working on. Sometimes sleep helps your brain
A very Merry Christmas and Happy New Year to you as well. Enjoy the holidays!
Tom
|
|
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