C# PDF 查看器
本文将探讨在 .NET 应用程序中查看 PDF 的各种方法。 本文将探讨查看PDF的各种方法。 在应用程序中查看PDF是一个常见需求,可以通过使用.NET的PDF库轻松解决。
IronPDF为MAUI项目提供了一个PDF查看器。 有关更多信息,请访问以下链接:“在 C# .NET 的 MAUI 中查看 PDF”。
开始使用IronPDF
立即在您的项目中开始使用IronPDF,并享受免费试用。
How to View PDF in .NET?
- Explore IronPDF Package on NuGet for .NET PDF Viewing
- Use HTML
iframe
tag in ASP.NET & MVC PDF viewer - Utilize WPF C# PDF Viewer using
WebBrowser
control - View PDF directly in Windows Forms PDF Viewer
- Utilize
System.Diagnostics.Process.Start
in Default System PDF Viewer
ASP.NET & MVC PDF 查看器
对于网页应用程序,PDF 可以在浏览器窗口或 iframe 中查看。 或者,您可以使用令人印象深刻的来自Mozilla的pdf.js库,它提供了一个完全用JavaScript编写的全面PDF查看器。
WPF C# PDF 查看器
要在WPF中直接查看PDF文档,您可以使用原生的WebBrowser控件。
Windows Forms PDF 查看器
对于在 Windows Forms (WinForms) 应用程序中直接查看 PDF 文档,WebBrowser 控件也是一个不错的选择。
在默认系统 PDF 查看器中查看 PDF
要从任何应用程序在外部窗口中打开PDF,我们可以使用一个涉及System.Diagnostics.Process.Start的技巧。
这通常会在支持查看 PDF 内容的默认网络浏览器中打开 PDF,或在安装了 Adobe Acrobat 的情况下打开 PDF。
:path=/static-assets/pdf/content-code-examples/how-to/net-pdf-viewer-default-pdf-viewer.cs
using IronPdf;
// Render any HTML fragment or document to HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
var outputPath = "ChromePdfRenderer.pdf";
// Export PDF document
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);
Imports IronPdf
' Render any HTML fragment or document to HTML
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>")
Private outputPath = "ChromePdfRenderer.pdf"
' Export PDF document
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)
IronPDF为MAUI项目提供了一个PDF查看器。 有关更多信息,请访问以下链接:“在 C# .NET 的 MAUI 中查看 PDF”。