C# PDF Viewers

Viewing PDFs in applications is a common request that is easily solved with the PDF Library for .NET.

Step 1

1. Installing IronPDF into Your Project

Use NuGet package manager to install IronPDF:
https://www.nuget.org/packages/IronPdf

P…


This content originally appeared on DEV Community and was authored by IronSoftware

Viewing PDFs in applications is a common request that is easily solved with the PDF Library for .NET.

Step 1

1. Installing IronPDF into Your Project

Use NuGet package manager to install IronPDF:
https://www.nuget.org/packages/IronPdf

PM > Install-Package IronPdf

IronPDF DLL can also be downloaded and manually installed.

How to Tutorial

2. PDF Viewers for .NET

We are working on a visual framework for viewing PDFs in C#/.Net - in the mean time you have lots of viable free options without resorting to Adobe Acrobat.

2.1. ASP.Net & MVC PDF viewer.

For web applications - PDFs can be viewed in a browser window or iframe. You may also use the amazing pdf.js library from mozilla to leverage a full PDF viewer written in pure javascript code.

https://mozilla.github.io/pdf.js/

2.2. WPF C# PDF Viewer

For viewing PDF documents directly in WPF you can use the native WebBrowser control.

2.3. Windows Forms PDF Viewer

For viewing PDF documents directly in windows forms (WinForms) applications the WebBrowser control is also a good choice.

2.4. Viewing a PDF in a the Default System PDF Viewer

To open a PDF from any application in an external window, we may use a trick involving System.Diagnostics.Process.Start.

This will generally open the PDF in the default web browser which supports viewing PDF content, or Adobe Acrobat if installed.

C#:

// Render any HTML fragment or document to HTML
var Renderer = new IronPdf.ChromePdfRenderer();
var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
var OutputPath = "ChromePdfRenderer.pdf";
PDF.SaveAs(OutputPath);
// This neat trick opens our PDF file so we can see the result in our default PDF viewer
System.Diagnostics.Process.Start(OutputPath);

VB:

' Render any HTML fragment or document to HTML
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>")
Dim OutputPath = "ChromePdfRenderer.pdf"
PDF.SaveAs(OutputPath)
' This neat trick opens our PDF file so we can see the result in our default PDF viewer
System.Diagnostics.Process.Start(OutputPath)


This content originally appeared on DEV Community and was authored by IronSoftware


Print Share Comment Cite Upload Translate Updates
APA

IronSoftware | Sciencx (2022-01-19T08:49:14+00:00) C# PDF Viewers. Retrieved from https://www.scien.cx/2022/01/19/c-pdf-viewers/

MLA
" » C# PDF Viewers." IronSoftware | Sciencx - Wednesday January 19, 2022, https://www.scien.cx/2022/01/19/c-pdf-viewers/
HARVARD
IronSoftware | Sciencx Wednesday January 19, 2022 » C# PDF Viewers., viewed ,<https://www.scien.cx/2022/01/19/c-pdf-viewers/>
VANCOUVER
IronSoftware | Sciencx - » C# PDF Viewers. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/19/c-pdf-viewers/
CHICAGO
" » C# PDF Viewers." IronSoftware | Sciencx - Accessed . https://www.scien.cx/2022/01/19/c-pdf-viewers/
IEEE
" » C# PDF Viewers." IronSoftware | Sciencx [Online]. Available: https://www.scien.cx/2022/01/19/c-pdf-viewers/. [Accessed: ]
rf:citation
» C# PDF Viewers | IronSoftware | Sciencx | https://www.scien.cx/2022/01/19/c-pdf-viewers/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.