Opening password protected files

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

Opening password protected files

Post by jPV » Wed Oct 24, 2018 6:08 pm

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: 2670
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair » 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.

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: Opening password protected files

Post by Juan Carlos » Tue Nov 06, 2018 11:51 am

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: 2670
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair » Wed Nov 07, 2018 5:42 pm

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: 194
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Opening password protected files

Post by jPV » Wed Nov 07, 2018 6:59 pm

Yes, I now tested that it works on Intel Mac, but doesn't work on PPC Mac.

User avatar
airsoftsoftwair
Posts: 2670
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Opening password protected files

Post by airsoftsoftwair » Sun Nov 11, 2018 10:19 pm

That's very suspicious :)

Post Reply