Opening password protected files

Discuss PDF file handling with the Polybios plugin here
Post Reply
User avatar
jPV
Posts: 600
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Opening password protected files

Post by jPV »

I just can't seem to be able to open password protected PDF files. Is there some tricks, requirements, certain formats that's supported, or what could be wrong? I've tried to download some test files from Internet, and also tried to create an encrypted file with Preview under OSX, but can't seem to get any of them open. I've tried to open files under MorphOS and OSX 10.5.8, and fails on both...

Here's one test:

Code: Select all

@REQUIRE "polybios"
f$="pdfpwtest.pdf"
If Not Exists(f$)
    ; Download a test file from http://www.novapdf.com/kb/pdf-example-files-created-with-novapdf-138.html
    ; The password should be "test"
    DownloadFile("http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-password.original.pdf", {File=f$})
EndIf
If Exists(f$)
    pdf.OpenDocument(1, f$, {Password = "test"}) ; <- Fails here always
    PDF_DOCUMENT=pdf.GetObjectType()
    pdfpages=GetAttribute(PDF_DOCUMENT, 1, #PDFATTRPAGES)
    DebugPrint(pdfpages)
EndIf
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair »

Works on Windows so it could be an endian issue if it fails on all PPC systems but works on x86... I'll try to fix it for the next version.
User avatar
Juan Carlos
Posts: 884
Joined: Mon Sep 06, 2010 1:02 pm

Re: Opening password protected files

Post by Juan Carlos »

airsoftsoftwair wrote: Fri Oct 26, 2018 10:57 pm Works on Windows so it could be an endian issue if it fails on all PPC systems but works on x86... I'll try to fix it for the next version.
Neither it works for 68k, only in Windows.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair »

Well, 68k is big endian as well so this just confirms my theory. The best test would be to compare the behaviour on PPC Linux/macOS to the behaviour on x86 Linux/macOS. If it works on x86 Linux/macOS but fails on PPC Linux/macOS, then we can be almost certain it's an endian issue. Any volunteers? :)
User avatar
jPV
Posts: 600
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Opening password protected files

Post by jPV »

Yes, I now tested that it works on Intel Mac, but doesn't work on PPC Mac.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair »

That's very suspicious :)
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair »

Code: Select all

- Fix [BigEndian]: Password-protected PDFs couldn't be opened on big endian architectures because of
  an endian issue in the encryption key generator in PDFium; when will people finally learn to write
  endian-independent code?
Post Reply