如何在python中更改已打开的pdf页面 [英] How to change page of already open pdf in python
问题描述
我具有标准的pdf链接,可以将文件打开到特定的ppage,但是如果文件已经打开,则页面不会更改,脚本只会打开已经打开的文件,我如何在打开的文件中导航文件?还是解决方法,请注意文件已打开,关闭并重新打开?
I have the standard pdf link made to open a file to a specific ppage, but if the file is already open, the page doesn't change, the script just opens the already open file, how can I navigate within an open file? or as a workaround, notice that the file is open, close it, and the reopen it?
path_to_pdf = os.path.abspath(openfile)
path_to_acrobat = os.path.abspath('C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe')
process = subprocess.Popen([path_to_acrobat, '/A', 'page=' + page, path_to_pdf], shell=False, stdout=subprocess.PIPE)
process.wait()
推荐答案
有时候杀死其他进程并不礼貌-特别是如果您的程序不是产生它的程序。在这种情况下,您可能更喜欢简单地启动另一个acrobat进程。要在Windows上执行此操作,请使用 / n
选项:
Sometimes it's not polite to kill other processes -- especially if your program is not the one that spawned it. In such a case you may prefer to simply launch another acrobat process. To do that on Windows, use the /n
option:
process = subprocess.Popen([path_to_acrobat, '/n', '/A', 'page=' + page, path_to_pdf], shell=False, stdout=subprocess.PIPE)
这篇关于如何在python中更改已打开的pdf页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!