Opening PDF Using subprocess.Popen Failing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening PDF Using subprocess.Popen Failing

Naftali
It actually doesn't fail but it 'cannot open in protected mode' (see here http://blogs.adobe.com/dmcmahon/2012/07/27/adobe-reader-cannot-open-protected-mode-due-to-a-problem-with-your-system-configuration/)

I am using subprocess.Popen("AcroRe32.exe /n <file.pdf>") which is the actuall adobe reader command I'd issue on the command line to open the pdf (the /n option opens it the file in a new instance of reader).

Now, when I issue the command straight from powershell, the pdf opens no problem, but when I open in my script (whether a .py or py2exe) I get the pop up complaining that the PDF cannot be opened in 'protected mode.' One of the options is to open it anyways, which works.

Looking into it (see the link in the first paragraph) my best guess is that it's due to something like "JS-invoked processes: Launching a process through JavaScript is not allowed with Protected Mode enabled."

But my naive understanding was that when I give Popen instruction, the command is handed off to windows and the called program is unaware of how it got called, so my thinking is that either that is incorrect or windows somehow 'cooperates' with reader to figure things out.

I am looking for *any* insight as to how to deal with this, and the 'turn off protected mode" option wont work for me.

Here is my code,

outputname = " unlocked.pdf"

commandstr = "qpdf --decrypt " + sys.argv[1] + outputname
os.system(commandstr)

new_command_str = "AcroRd32.exe /n" + outputname
subprocess.Popen(new_command_str)

sys.exit(0)
 

Reply | Threaded
Open this post in threaded view
|

Opening PDF Using subprocess.Popen Failing

Laura Creighton-2
In a message of Fri, 19 Jun 2015 10:24:56 -0700, Naftali writes:

>It actually doesn't fail but it 'cannot open in protected mode' (see here http://blogs.adobe.com/dmcmahon/2012/07/27/adobe-reader-cannot-open-protected-mode-due-to-a-problem-with-your-system-configuration/)
>
>I am using subprocess.Popen("AcroRe32.exe /n <file.pdf>") which is the actuall adobe reader command I'd issue on the command line to open the pdf (the /n option opens it the file in a new instance of reader).
>
>Now, when I issue the command straight from powershell, the pdf opens no problem, but when I open in my script (whether a .py or py2exe) I get the pop up complaining that the PDF cannot be opened in 'protected mode.' One of the options is to open it anyways, which works.
>
>Looking into it (see the link in the first paragraph) my best guess is that it's due to something like "JS-invoked processes: Launching a process through JavaScript is not allowed with Protected Mode enabled."
>
>But my naive understanding was that when I give Popen instruction, the command is handed off to windows and the called program is unaware of how it got called, so my thinking is that either that is incorrect or windows somehow 'cooperates' with reader to figure things out.
>
>I am looking for *any* insight as to how to deal with this, and the 'turn off protected mode" option wont work for me.
>
>Here is my code,
>
>outputname = " unlocked.pdf"
>
>commandstr = "qpdf --decrypt " + sys.argv[1] + outputname
>os.system(commandstr)
>
>new_command_str = "AcroRd32.exe /n" + outputname
>subprocess.Popen(new_command_str)
>
>sys.exit(0)
>
>--
>https://mail.python.org/mailman/listinfo/python-list

I don't have a windows system to test this on, but I read
https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html

It looks like if you put your output file one of the places that
Acrobat allows, then things might work.  You can then move the thing
later to where you want it to go.

There is also this tantalising FAQ entry:


      When custom policies fail for certain workflows, what are the
      options other than disabling Protected Mode?

      One option is to add custom policies to bypass protected mode
      restrictions.

Now, I haven't found out _how you do that_ yet, but seems like a
promising area for research.

Laura

Reply | Threaded
Open this post in threaded view
|

Opening PDF Using subprocess.Popen Failing

Naftali
In reply to this post by Naftali
On Friday, June 19, 2015 at 1:25:12 PM UTC-4, Naftali wrote:

> It actually doesn't fail but it 'cannot open in protected mode' (see here http://blogs.adobe.com/dmcmahon/2012/07/27/adobe-reader-cannot-open-protected-mode-due-to-a-problem-with-your-system-configuration/)
>
> I am using subprocess.Popen("AcroRe32.exe /n <file.pdf>") which is the actuall adobe reader command I'd issue on the command line to open the pdf (the /n option opens it the file in a new instance of reader).
>
> Now, when I issue the command straight from powershell, the pdf opens no problem, but when I open in my script (whether a .py or py2exe) I get the pop up complaining that the PDF cannot be opened in 'protected mode.' One of the options is to open it anyways, which works.
>
> Looking into it (see the link in the first paragraph) my best guess is that it's due to something like "JS-invoked processes: Launching a process through JavaScript is not allowed with Protected Mode enabled."
>
> But my naive understanding was that when I give Popen instruction, the command is handed off to windows and the called program is unaware of how it got called, so my thinking is that either that is incorrect or windows somehow 'cooperates' with reader to figure things out.
>
> I am looking for *any* insight as to how to deal with this, and the 'turn off protected mode" option wont work for me.
>
> Here is my code,
>
> outputname = " unlocked.pdf"
>
> commandstr = "qpdf --decrypt " + sys.argv[1] + outputname
> os.system(commandstr)
>
> new_command_str = "AcroRd32.exe /n" + outputname
> subprocess.Popen(new_command_str)
>
> sys.exit(0)

Yes, this is excellent. thank you so much. Will update the list when this works out.

Reply | Threaded
Open this post in threaded view
|

Opening PDF Using subprocess.Popen Failing

Naftali
In reply to this post by Naftali
On Friday, June 19, 2015 at 1:25:12 PM UTC-4, Naftali wrote:

> It actually doesn't fail but it 'cannot open in protected mode' (see here http://blogs.adobe.com/dmcmahon/2012/07/27/adobe-reader-cannot-open-protected-mode-due-to-a-problem-with-your-system-configuration/)
>
> I am using subprocess.Popen("AcroRe32.exe /n <file.pdf>") which is the actuall adobe reader command I'd issue on the command line to open the pdf (the /n option opens it the file in a new instance of reader).
>
> Now, when I issue the command straight from powershell, the pdf opens no problem, but when I open in my script (whether a .py or py2exe) I get the pop up complaining that the PDF cannot be opened in 'protected mode.' One of the options is to open it anyways, which works.
>
> Looking into it (see the link in the first paragraph) my best guess is that it's due to something like "JS-invoked processes: Launching a process through JavaScript is not allowed with Protected Mode enabled."
>
> But my naive understanding was that when I give Popen instruction, the command is handed off to windows and the called program is unaware of how it got called, so my thinking is that either that is incorrect or windows somehow 'cooperates' with reader to figure things out.
>
> I am looking for *any* insight as to how to deal with this, and the 'turn off protected mode" option wont work for me.
>
> Here is my code,
>
> outputname = " unlocked.pdf"
>
> commandstr = "qpdf --decrypt " + sys.argv[1] + outputname
> os.system(commandstr)
>
> new_command_str = "AcroRd32.exe /n" + outputname
> subprocess.Popen(new_command_str)
>
> sys.exit(0)


I am running the script via powershell. that sounds very promising. I'm going to read the link Laura pointed to upthread and see what happens outside powershell on Monday when I get back to the windows environment.

But thank you for the heads up cause that makes a lot sense.