launching adobe reader with arguments from os.system call

Martin Miller ggrp1.20.martineau at dfgh.net
Tue Sep 6 17:05:18 EDT 2005


Greg Miller wrote:
> Currently I am launching adobe reader using the following call:
> os.system("path.file.pdf")
> this works fine for opening the pdf doc at the beginning. We would like
> to enhance this and open the document to either a page or a nameddest
> in the doc.  The syntax for that in the DOS command prompt world is:
> acroRd32.exe /A "nameddest=Before You Begin" "path.file.pdf"
> However the os.system call won't allow me to call reader using that
> syntax.  Does anyone know how I can launch the Reader application and
> pass in the parameters required to allow the document to be opened to
> the named destination?  Thanks in advance!!

I'm not sure how/if you can do what you want with os.system(), but this
is what I've used to pass arguments directly to applications on
Windows:
>    # spawn text editor on file
>    import os
>    applpath = r'C:\Windows\system32\notepad.exe'
>    filepath =  r'D:\My Documents\somefile.txt'
>    os.spawnv(
>        os.P_WAIT,
>        applpath,
>        [ # argument list
>            applpath,
>            filepath
>        ]
>    )

A downside is that it requires you to know the full path to the
application, 'acroRd32.exe' in your case. On the other hand, I think
you could pass just about any argument values (as strings) that you
wished in the list passed as the third argument.

HTH,
-Martin




More information about the Python-list mailing list