Print Page | Close Window

Error 404 when trying to load encrypted PDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3683
Printed Date: 27 Apr 24 at 7:02PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Error 404 when trying to load encrypted PDF
Posted By: user285
Subject: Error 404 when trying to load encrypted PDF
Date Posted: 15 Mar 19 at 12:32PM
Hi,

I'm experiencing difficulties when trying to open an encrypted PDF.
Opening in Adobe Reader or another PDF viewer is no problem.

LoadFromString or LoadFromFile gives the same result.
LastErrorCode is 404 - Invalid password.

It seems I can open encrypted PDF files, just not the ones encrypted with PDFBox.

QuickPDF:
  • all encrypted files work.

QPDF:
  • test-qpdf-R5.pdf = PDF 1.7 Adobe Extension Level 3 (Acrobat 9) = OK.
  • test-qpdf-R6.pdf = PDF 1.7 Adobe Extension Level 8 (Acrobat X) 256-bit AES = OK.

PDFBox:
  • test-pdfbox-128.pdf = PDF 1.7 128-bit AES = Not OK.
  • test-pdfbox-256.pdf = PDF 1.7 256-bit AES = Not OK.

Test files available at: https://we.tl/t-G0JnQTa4Th

Any ideas?

Thanks!



Replies:
Posted By: Ingo
Date Posted: 15 Mar 19 at 1:45PM
Hi User285,

the PDFbox-files are buggy made.
The 100 mb of a main pdf-reader installation can handle this problem but not the few mb of a slim line library (with many functionality) like QuickPDF.
If you're looking into the PDFbox-files with Notepad you#ll find the pdf-version on the first line.
There's "%PDF-1.4" in both files. Later in the sources there is a 1.7 but that's not relevant.
So you have two files from PDFbox:
One is made as AES/128 bit and the pdf-specs says that pdf-version have to be at least 1.6...
The second one is made as AES/256 bit and the pdf-specs says that at least 1.7 is necessary.
In both files at the beginning there's a 1.4 ... and that's not okay for QuickPDF.

Here's a short sample in Delphi which always work with any correct pdf-documents:

// . .  .
   QP := TDebenuPDFLibrary1611.Create;
   try
      QP.LoadFromFile(Edit1.Text, '');

      If ( QP.EncryptionStatus > 0 ) Then
         QP.Decrypt;
// . . .

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: user285
Date Posted: 15 Mar 19 at 2:03PM
Originally posted by Ingo Ingo wrote:

Hi User285,

the PDFbox-files are buggy made.
The 100 mb of a main pdf-reader installation can handle this problem but not the few mb of a slim line library (with many functionality) like QuickPDF.
If you're looking into the PDFbox-files with Notepad you#ll find the pdf-version on the first line.
There's "%PDF-1.4" in both files. Later in the sources there is a 1.7 but that's not relevant.
So you have two files from PDFbox:
One is made as AES/128 bit and the pdf-specs says that pdf-version have to be at least 1.6...
The second one is made as AES/256 bit and the pdf-specs says that at least 1.7 is necessary.
In both files at the beginning there's a 1.4 ... and that's not okay for QuickPDF.

Here's a short sample in Delphi which always work with any correct pdf-documents:

// . .  .
   QP := TDebenuPDFLibrary1611.Create;
   try
      QP.LoadFromFile(Edit1.Text, '');

      If ( QP.EncryptionStatus > 0 ) Then
         QP.Decrypt;
// . . .

Cheers and welcome here,
Ingo

Thank you for your reply.

I forgot to mention I use the .NET version (dll) of QuickPDF.

The result from "LoadFromFile" or "LoadFromString" is always 0, so .Decrypt function doesn't do anything.

result = QP.LoadFromFile(file, "")
If QP.EncryptionStatus > 0 Then
     QP.Decrypt()

result = 0.
So EncryptionStatus can't be checked = 0.



Posted By: Ingo
Date Posted: 15 Mar 19 at 7:45PM
Read in the relevant pdf-content - without QuickPDF - in a stream or string.
Search for AES and 256 or 128...
Check the first characters (which version?)...
Change them if necessary...
And then LoadFromStream or LoadFromString...
It's not as easy as i've written it but it's not too complicated ;-)
Please keep in mind:
The library is okay - the pdf-document is mal formed ;-)



-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk