Python Forum

Full Version: Open PDF in certain page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I am beginner in Python, and I need to open PDF file in specific page. I found this command, bit i don`t know how to change number of page to my variable.
process = subprocess.Popen(["C:\\Program Files\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe", '/A', 'page=15',"C:\\Users\\Narek\\Desktop\\Bararan-2018.pdf"], shell=False, stdout=subprocess.PIPE)
process.wait()
You can try this
def open_pdf(filename, page=1):
    return subprocess.Popen(["C:\\Program Files\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe", '/A', 'page={:d}'.format(page), filename], stdout=subprocess.PIPE)

process = open_pdf("C:\\Users\\Narek\\Desktop\\Bararan-2018.pdf", page=15)
process.wait()
(Jan-25-2018, 09:46 AM)Gribouillis Wrote: [ -> ]You can try this
def open_pdf(filename, page=1):
    return subprocess.Popen(["C:\\Program Files\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe", '/A', 'page={:d}'.format(page), filename], stdout=subprocess.PIPE)

process = open_pdf("C:\\Users\\Narek\\Desktop\\Bararan-2018.pdf", page=15)
process.wait()

Thanks, I used it in application on my computer. But now I need to use it on other computers. So how can I find .exe file of Reader on other computers?
(Mar-12-2018, 09:05 AM)ammann Wrote: [ -> ]how can I find .exe file of Reader on other computers?
You can try
import shutil
reader = shutil.which('AcroRd32') # or perhaps AcroRd32.exe
Thanks, now I am trying to do this on web.
To open pdf on specific page in browser, I should use #page=[page number], as mentioned therehttps://helpx.adobe.com/acrobat/kb/link-...robat.html
But Google Chrome converts # in link to %23 and link doesn`t work.
How can I solve this problem?