Aleksa
Aleksa

Reputation: 3104

Opening pdf file

I wanna open pdf file from python console, I can do it with os.system(filename), it will open in adobe reader, but the problem is that os.system also opens a command prompt, is there another way that won't open command prompt?

Upvotes: 29

Views: 129972

Answers (4)

Daniel Wärnå
Daniel Wärnå

Reputation: 788

Try:

import subprocess
subprocess.Popen([file],shell=True)

Upvotes: 33

Raj Stha
Raj Stha

Reputation: 1091

import os
os.startfile(filename)

Upvotes: 18

Astrophe
Astrophe

Reputation: 574

This is a bit late but nobody mentioned:

open("file_name.pdf")

Upvotes: -8

Static Void
Static Void

Reputation: 688

import webbrowser
webbrowser.open_new(r'file://C:\path\to\file.pdf')

Upvotes: 26

Related Questions