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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Problems with DecryptFile Function
  FAQ FAQ  Forum Search   Register Register  Login Login

Problems with DecryptFile Function

 Post Reply Post Reply
Author
Message
Shotgun Tom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 Aug 09
Location: Phoenix, AZ
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shotgun Tom Quote  Post ReplyReply Direct Link To This Post Topic: Problems with DecryptFile Function
    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
Back to Top
Michel_K17 View Drop Down
Newbie
Newbie
Avatar
www.exp-systems.com

Joined: 25 Jan 03
Status: Offline
Points: 297
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michel_K17 Quote  Post ReplyReply Direct Link To This Post Posted: 19 Dec 09 at 11:16PM
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
Back to Top
Shotgun Tom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 Aug 09
Location: Phoenix, AZ
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shotgun Tom Quote  Post ReplyReply Direct Link To This Post Posted: 20 Dec 09 at 2:03AM
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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 20 Dec 09 at 12:03PM
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!


Back to Top
Shotgun Tom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 Aug 09
Location: Phoenix, AZ
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shotgun Tom Quote  Post ReplyReply Direct Link To This Post Posted: 20 Dec 09 at 2:52PM
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 Wacko
 
A very Merry Christmas and Happy New Year to you as well.  Enjoy the holidays!
 
Tom
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store