Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I Want to display the Pdf file in my WPF Application using mvvm

What I have tried:

I Want to display the Pdf file in my WPF Application using mvvm
Posted
Updated 13-Jun-16 5:33am

WPF has no facility to display a PDF file on it's own. You have to use a 3rd party control to do it. Just Google for "show pdf in wpf application" and you'll come up with a ton of examples.
 
Share this answer
 
You cannot guarantee to display PDF file, by definition. PDF is not a part of W3 standards; and I would be glad if it never become standardized with the Web; it's concept is very foreign to Web. It does not present any problems: the content type is standardized. You just need to provide the file by the fragment of HTML code generated on your server side, such as
C#
<a href="yourPdfFile.pdf">Your PDF file</a>

To do so, you would need to have this file on your server side, in a file system, or create such file dynamically. This is not always acceptable. You can also generate PDF content on the fly, make it an ASP.NET page returning the content in HTTP response. To do so, your server-side code should generate the content in HTTPResponse and write appropriate content-type header, with the content type "application/pdf". Please see:
HttpResponse Class (System.Web),
HttpResponse.ContentType Property (System.Web),
Media Types (IANA supports the standard for all media types).

This is a set of references to PDF libraries you can use: http://csharp-source.net/open-source/pdf-libraries.


Here is how it will work:

You cannot assume that anything supporting PDF is installed on the client machine. The client can have PDF plug-in enabled in the browser, then it will be shown in the browser window. If not, the user will be given a choice to open the PDF in a default PDF viewer. Such viewer may or may not exist; if not, the user will have a choice to save the file locally and open it later; the software for opening the file also may or may not exist, but this is not a problem and not your concern.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900