C# PDF 檢視器
本文將探討在 .NET 應用程式中查看 PDF 的各種方法。 本文將探討查看PDF的各種方法。 使用 .NET 的 PDF Library 可以輕鬆解決應用程式中查看 PDF 的常見需求。
IronPDF為MAUI專案提供PDF查看器。 如需更多資訊,請造訪以下連結:「在 MAUI 中查看 C# .NET 的 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 中查看。 或者,您可以利用令人印象深刻的pdf.js圖書館來自Mozilla,它提供了一個完全用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 中打開。
: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查看器。 如需更多資訊,請造訪以下連結:「在 MAUI 中查看 C# .NET 的 PDF」。