如何使用Python在浏览器中预览pdf文件?

时间:2017-01-29 09:48:43

标签: python pdf preview

我想在浏览器中预览pdf文件,然后重命名该文件,然后将其邮寄给某人。是否可以使用python脚本执行此操作?

1 个答案:

答案 0 :(得分:1)

有一个使用浏览器的模块

import webbrowser
new = 2 # open in a new tab, if possible

# open a public URL, in this case, the webbrowser docs
url = "http://docs.python.org/library/webbrowser.html"
webbrowser.open(url,new=new)

# open an HTML file on my own (Windows) computer
url = "file://X:/MiscDev/language_links.html"
webbrowser.open(url,new=new)

示例来源here;文件here。 如果浏览器可以打开它,它应该与Pdf文件相同而不是html。

如果您想在预览时暂停,可以使用

wait = input("PRESS ENTER TO CONTINUE.")

重命名有答案here,您使用os.rename(src, dst)

电子邮件已经回复here,文档here

现在把它们放在一起!