[英]how to display pdf file contents as well as its full name in the browser using cgi python script?
[英]How to preview pdf file in browser using Python?
我想在瀏覽器中預覽 pdf 文件,然后重命名該文件,然后將其郵寄給某人。 是否可以使用 python 腳本來做到這一點?
有一個模塊可以使用瀏覽器
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)
示例的來源在這里; 文檔在這里。 如果瀏覽器可以打開 Pdf 文件而不是 html,它應該以相同的方式工作。
如果要在預覽時暫停,可以使用
wait = input("PRESS ENTER TO CONTINUE.")
重命名在這里有一個答案,你使用os.rename(src, dst) 。
現在把它們放在一起!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.