Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a PDF file

Tags:

powershell

pdf

I'm writing an PowerShell application which aim to display a PDF file. PDF can be display in some control e.g. WebBrowser. The PDF file will be located on the disk, not in the Internet.

I was trying to do it with WebBrowser Control and Itext Library, but it didn't work.

Tiny part of my code:

$WebBrowser.Navigate("C:\...\My_file.pdf")
$WebBrowser.Url = "C:\...\My_file.pdf"

Do you have any tips for me how to proceed in this case?

like image 600
mystery-user Avatar asked Dec 14 '22 23:12

mystery-user


2 Answers

If you just want to open a pdf, I would recommend you to use the Start-Process cmdlet to open the PDF using the local standard PDF reader:

Start-Process ((Resolve-Path "C:\..\My_file.pdf").Path)
like image 52
Martin Brandl Avatar answered Dec 29 '22 21:12

Martin Brandl


If you are just trying to open a pdf file. you could do something like:

& <path to program> <path to file>

ex:

& "C:\Program Files\Internet Explorer\iexplore.exe" "C:\Users\user\Desktop\diskspaceauth-2017-05-08.pdf"
like image 23
fampop Avatar answered Dec 29 '22 22:12

fampop