IRONPDF 사용 How to Create an ASP.NET Core MVC PdfViewer with IronPDF 커티스 차우 업데이트됨:12월 4, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 Create an ASP.NET Core MVC PDF viewer using IronPDF's Chrome-based rendering engine to display PDF files inline in browsers, generate dynamic PDFs from HTML content, and control whether users view or download documents—all without external plugins or dependencies. Modern browsers include a built-in PDF viewer that automatically activates when a web application serves PDF files with the correct MIME type. This eliminates the need for third-party tools or plugins, allowing users to display PDF documents directly in their browser. IronPDF, a frequently updated .NET PDF library, makes it simple to generate, render, and display PDF files within ASP.NET Core MVC applications. In this article, we'll show you how to create an ASP.NET Core MVC PDF viewer web application using IronPDF's Chrome-based rendering engine. The primary focus of this guide is achieving pixel-perfect results while maintaining high performance. 지금 바로 IronPDF으로 시작하세요. 무료로 시작하세요 How Do Modern Browsers Display PDF Files? Modern browsers such as Chrome, Firefox, Edge, and Safari include native PDF viewer functionality. When your ASP.NET Core application returns a file with the application/pdf content type, the browser renders the PDF document inline without requiring Adobe Acrobat or external plugins. This built-in PDF viewer supports essential features such as text selection, printing, zoom controls, bookmarks, and page navigation, creating a complete document-viewing experience. To securely serve existing files, it's best practice to use the hosting environment to locate them rather than relying on directory paths that might change between development and production. Additionally, using a file stream is often more memory-efficient than loading whole byte arrays for large documents. using Microsoft.AspNetCore.Mvc; public class DocumentController : Controller { public IActionResult ViewPdf() { // Path to an existing PDF file in the wwwroot folder string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "documents", "sample.pdf"); byte[] fileBytes = System.IO.File.ReadAllBytes(path); // Return file for inline browser display return File(fileBytes, "application/pdf"); } } using Microsoft.AspNetCore.Mvc; public class DocumentController : Controller { public IActionResult ViewPdf() { // Path to an existing PDF file in the wwwroot folder string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "documents", "sample.pdf"); byte[] fileBytes = System.IO.File.ReadAllBytes(path); // Return file for inline browser display return File(fileBytes, "application/pdf"); } } $vbLabelText $csharpLabel This simple approach works effectively for serving static PDF files stored on your server. For more advanced scenarios, you might want to load PDFs from memory or Azure Blob Storage, which can improve scalability and reduce server storage requirements. What Does a PDF Look Like When Displayed in the Browser? The code above reads an existing PDF file from the server and returns it to the browser. The File() method accepts a byte array and a content type, instructing the browser's document viewer to render the content inline. This approach works across all modern browsers on both desktop and mobile devices, providing a consistent experience for all users. How Can Developers Generate PDF Documents Dynamically? Static PDF files are useful, but many web applications require dynamically generated documents. IronPDF's ChromePdfRenderer class converts HTML content into professionally rendered PDF files. Install IronPDF via NuGet packages in Visual Studio to get started. You can include external assets, such as CSS for your specific theme or JavaScript for charts, directly in the HTML string. The rendering engine supports modern web standards including CSS3, JavaScript ES6+, and web fonts. using IronPdf; using Microsoft.AspNetCore.Mvc; public class ReportController : Controller { public IActionResult GenerateReport() { var renderer = new ChromePdfRenderer(); // HTML content with CSS styling string html = @" <html> <head> <style> body { font-family: Arial, sans-serif; padding: 40px; } h1 { color: #2c3e50; } .report-body { line-height: 1.6; } </style> </head> <body> <h1>Monthly Sales Report</h1> <div class='report-body'> <p>Generated: " + DateTime.Now.ToString("MMMM dd, yyyy") + @"</p> <p>This report contains the latest sales figures.</p> </div> </body> </html>"; PdfDocument pdf = renderer.RenderHtmlAsPdf(html); return File(pdf.BinaryData, "application/pdf"); } } using IronPdf; using Microsoft.AspNetCore.Mvc; public class ReportController : Controller { public IActionResult GenerateReport() { var renderer = new ChromePdfRenderer(); // HTML content with CSS styling string html = @" <html> <head> <style> body { font-family: Arial, sans-serif; padding: 40px; } h1 { color: #2c3e50; } .report-body { line-height: 1.6; } </style> </head> <body> <h1>Monthly Sales Report</h1> <div class='report-body'> <p>Generated: " + DateTime.Now.ToString("MMMM dd, yyyy") + @"</p> <p>This report contains the latest sales figures.</p> </div> </body> </html>"; PdfDocument pdf = renderer.RenderHtmlAsPdf(html); return File(pdf.BinaryData, "application/pdf"); } } $vbLabelText $csharpLabel How Does HTML Content Appear After PDF Generation? This example demonstrates how IronPDF transforms an HTML string into a PDF document. The ChromePdfRenderer uses a Chromium-based engine, ensuring accurate CSS rendering and JavaScript support. The generated PDF maintains all styling defined in the HTML, making it ideal for creating reports, invoices, and other documents that require consistent formatting. The controller handles the request and returns the rendered output to users. For additional information and code examples on HTML to PDF conversion, explore IronPDF's comprehensive documentation. You can also generate PDFs from CSHTML Razor views, URLs, or even Markdown content. What Options Exist for Inline Display vs. Download? Sometimes users need to download PDF files rather than view them in the browser. You might have a link on your home page that directs users to these reports. How the browser handles the response depends on the Content-Disposition header. Understanding this distinction is crucial for providing the right user experience. using IronPdf; using Microsoft.AspNetCore.Mvc; public class PdfController : Controller { public IActionResult DisplayInline() { var renderer = new ChromePdfRenderer(); // Configure rendering options for better output renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait; renderer.RenderingOptions.MarginTop = 25; renderer.RenderingOptions.MarginBottom = 25; PdfDocument pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_42___"); // Display PDF inline in browser return File(pdf.BinaryData, "application/pdf"); } public IActionResult DownloadPdf() { var renderer = new ChromePdfRenderer(); // Set additional options for downloaded PDFs renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter; renderer.RenderingOptions.EnableJavaScript = true; PdfDocument pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_43___"); // Prompt download with specified filename return File(pdf.BinaryData, "application/pdf", "webpage-report.pdf"); } } using IronPdf; using Microsoft.AspNetCore.Mvc; public class PdfController : Controller { public IActionResult DisplayInline() { var renderer = new ChromePdfRenderer(); // Configure rendering options for better output renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait; renderer.RenderingOptions.MarginTop = 25; renderer.RenderingOptions.MarginBottom = 25; PdfDocument pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_42___"); // Display PDF inline in browser return File(pdf.BinaryData, "application/pdf"); } public IActionResult DownloadPdf() { var renderer = new ChromePdfRenderer(); // Set additional options for downloaded PDFs renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter; renderer.RenderingOptions.EnableJavaScript = true; PdfDocument pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_43___"); // Prompt download with specified filename return File(pdf.BinaryData, "application/pdf", "webpage-report.pdf"); } } $vbLabelText $csharpLabel When Should I Use Inline Display Instead of Download? The difference between these two controller actions lies in the third parameter of the File() method. When you provide a filename, ASP.NET Core automatically adds the Content-Disposition: attachment header, prompting users to download the file. Omitting the filename parameter uses the default inline display mode. This flexibility allows your app to support both viewing scenarios based on user needs or project requirements. For enhanced control, you can also implement custom headers or configure paper size and orientation settings. How Can Razor Pages Integrate with .NET Core PDF Generation? Razor Pages in ASP.NET Core MVC provide another approach for implementing a .NET PDF viewer. The page model can generate and return PDF files using the same IronPDF functionality. This pattern works particularly well for applications already using Razor Pages for their architecture. using IronPdf; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; public class InvoiceModel : PageModel { public IActionResult OnGet(int id) { var renderer = new ChromePdfRenderer(); // Configure rendering options renderer.RenderingOptions.MarginTop = 20; renderer.RenderingOptions.MarginBottom = 20; renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; // Add header and footer renderer.RenderingOptions.TextHeader.CenterText = "Invoice Document"; renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}"; renderer.RenderingOptions.TextFooter.FontSize = 10; string html = $@" <html> <head> <style> body {{ font-family: 'Segoe UI', Arial, sans-serif; padding: 40px; }} h1 {{ color: #1a5490; border-bottom: 2px solid #1a5490; padding-bottom: 10px; }} .invoice-details {{ margin: 20px 0; }} table {{ width: 100%; border-collapse: collapse; }} th, td {{ padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }} </style> </head> <body> <h1>Invoice #{id}</h1> <div class='invoice-details'> <p><strong>Date:</strong> {DateTime.Now:yyyy-MM-dd}</p> <p><strong>Due Date:</strong> {DateTime.Now.AddDays(30):yyyy-MM-dd}</p> </div> <table> <tr> <th>Description</th> <th>Amount</th> </tr> <tr> <td>Professional Services</td> <td>$1,500.00</td> </tr> </table> <p style='margin-top: 40px;'>Thank you for your business!</p> </body> </html>"; PdfDocument pdf = renderer.RenderHtmlAsPdf(html); return File(pdf.BinaryData, "application/pdf"); } } using IronPdf; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; public class InvoiceModel : PageModel { public IActionResult OnGet(int id) { var renderer = new ChromePdfRenderer(); // Configure rendering options renderer.RenderingOptions.MarginTop = 20; renderer.RenderingOptions.MarginBottom = 20; renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; // Add header and footer renderer.RenderingOptions.TextHeader.CenterText = "Invoice Document"; renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}"; renderer.RenderingOptions.TextFooter.FontSize = 10; string html = $@" <html> <head> <style> body {{ font-family: 'Segoe UI', Arial, sans-serif; padding: 40px; }} h1 {{ color: #1a5490; border-bottom: 2px solid #1a5490; padding-bottom: 10px; }} .invoice-details {{ margin: 20px 0; }} table {{ width: 100%; border-collapse: collapse; }} th, td {{ padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }} </style> </head> <body> <h1>Invoice #{id}</h1> <div class='invoice-details'> <p><strong>Date:</strong> {DateTime.Now:yyyy-MM-dd}</p> <p><strong>Due Date:</strong> {DateTime.Now.AddDays(30):yyyy-MM-dd}</p> </div> <table> <tr> <th>Description</th> <th>Amount</th> </tr> <tr> <td>Professional Services</td> <td>$1,500.00</td> </tr> </table> <p style='margin-top: 40px;'>Thank you for your business!</p> </body> </html>"; PdfDocument pdf = renderer.RenderHtmlAsPdf(html); return File(pdf.BinaryData, "application/pdf"); } } $vbLabelText $csharpLabel What Rendering Options Are Available for PDF Customization? This Razor Pages example demonstrates how the OnGet handler generates a PDF from a URL parameter. The RenderingOptions property allows customization of margins, page orientation, and other settings. You can also add headers and footers, configure page numbers, or set up custom paper sizes. For additional information, explore IronPDF's rendering options documentation. Advanced features include watermarking, PDF compression, and digital signatures. You can also implement form creation or merge multiple PDFs for more complex document workflows. What Are the Key Takeaways for Building PDF Viewers? Creating an ASP.NET Core MVC viewer for PDF documents combines browser-native capabilities with IronPDF's powerful generation features. The built-in PDF viewer in modern browsers handles display, print, and navigation functionality automatically when your ASP.NET controller returns files with the correct MIME type. IronPDF simplifies the creation of professional PDF documents from HTML, URLs, or existing files with full support for CSS, JavaScript, and custom rendering options. Key benefits of using IronPDF for PDF viewing in ASP.NET Core include: No external viewer plugins required Chrome rendering engine ensures accurate HTML/CSS rendering Support for JavaScript and dynamic content Flexible options for inline viewing and file downloads Extensive customization options for professional output Cross-platform support including Linux and Docker Whether building a simple document viewer to display PDF files or implementing a complete report generation system, IronPDF provides the tools and features needed for seamless PDF integration. The library integrates smoothly with your ASP.NET Core web application, supporting both traditional MVC controllers and modern Razor Pages approaches. For production deployments, consider performance optimization techniques such as async rendering and proper memory management. You can also explore advanced features like PDF/A compliance for long-term archival or PDF security for sensitive documents. Start your free trial to explore IronPDF's full capabilities, or purchase a license for production use. Visit our comprehensive documentation to learn more about advanced features and best practices. 자주 묻는 질문 ASP.NET Core MVC 애플리케이션에서 PDF 파일을 표시하려면 어떻게 해야 하나요? IronPDF를 사용하여 ASP.NET Core MVC 애플리케이션에서 PDF 파일을 표시할 수 있습니다. 최신 내장 PDF 뷰어를 사용하여 브라우저에서 직접 PDF 파일을 생성, 렌더링 및 표시할 수 있습니다. 브라우저에서 PDF를 보려면 타사 플러그인이 필요하나요? 아니요, 최신 브라우저에는 올바른 MIME 유형의 PDF 파일을 제공할 때 자동으로 활성화되는 PDF 뷰어가 내장되어 있습니다. IronPDF는 PDF가 올바르게 제공되도록 도와줍니다. ASP.NET Core MVC에서 IronPDF를 사용하면 어떤 이점이 있나요? IronPDF는 ASP.NET Core MVC 애플리케이션 내에서 PDF 문서를 생성하고 렌더링하는 프로세스를 간소화하여 생산성을 향상하고 PDF 관리를 간소화하는 .NET PDF 라이브러리입니다. IronPDF는 기존 브라우저 PDF 뷰어와 함께 사용할 수 있나요? 예, IronPDF는 브라우저에서 자동으로 표시할 수 있도록 PDF가 올바른 MIME 유형으로 제공되도록 하여 기존 브라우저 PDF 뷰어와 원활하게 작동합니다. IronPDF는 자주 업데이트되나요? 예, IronPDF는 자주 업데이트되는 .NET PDF 라이브러리로, ASP.NET Core MVC 애플리케이션에서 PDF 문서를 처리하기 위한 최신 기능 및 개선 사항을 제공합니다. IronPDF는 웹 애플리케이션에서 PDF 생성을 어떻게 처리하나요? IronPDF는 다양한 콘텐츠 유형에서 PDF를 생성하는 강력한 기능을 제공하여 개발자가 웹 애플리케이션 내에서 동적이고 대화형 PDF 문서를 만들 수 있도록 지원합니다. PDF 파일을 제공하려면 어떤 MIME 유형을 사용해야 하나요? 브라우저에서 제대로 표시되도록 하려면 PDF 파일은 MIME 유형 'application/pdf'로 제공되어야 합니다. IronPDF는 이러한 측면을 효율적으로 관리하는 데 도움을 줄 수 있습니다. IronPDF에서 PDF 렌더링을 사용자 지정할 수 있나요? 예, IronPDF는 PDF 렌더링을 위한 광범위한 사용자 지정 옵션을 제공하여 특정 디자인 및 기능 요구 사항을 충족하도록 출력을 조정할 수 있습니다. IronPDF는 ASP.NET Core MVC 애플리케이션만 지원하나요? IronPDF는 ASP.NET Core MVC 애플리케이션에 탁월하지만, 다른 .NET 애플리케이션과 함께 사용하여 PDF 기능을 처리할 수 있는 다목적 도구이기도 합니다. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 업데이트됨 1월 22, 2026 How to Create PDF Documents in .NET with IronPDF: Complete Guide Discover effective methods to create PDF files in C# for developers. Enhance your coding skills and streamline your projects. Read the article now! 더 읽어보기 업데이트됨 1월 21, 2026 How to Merge PDF Files in VB.NET: Complete Tutorial Merge PDF VB NET with IronPDF. Learn to combine multiple PDF files into one document using simple VB.NET code. Step-by-step examples included. 더 읽어보기 업데이트됨 1월 21, 2026 C# PDFWriter Tutorial: Create PDF Documents in .NET Learn to create PDFs efficiently using C# PDFWriter with this step-by-step guide for developers. Read the article to enhance your skills today! 더 읽어보기 ASP .NET PDF Signatures Guide: Add Digital Signatures to PDFs in .NET Core ProjectsConvert JPEG to PDF .NET: The Compl...
업데이트됨 1월 22, 2026 How to Create PDF Documents in .NET with IronPDF: Complete Guide Discover effective methods to create PDF files in C# for developers. Enhance your coding skills and streamline your projects. Read the article now! 더 읽어보기
업데이트됨 1월 21, 2026 How to Merge PDF Files in VB.NET: Complete Tutorial Merge PDF VB NET with IronPDF. Learn to combine multiple PDF files into one document using simple VB.NET code. Step-by-step examples included. 더 읽어보기
업데이트됨 1월 21, 2026 C# PDFWriter Tutorial: Create PDF Documents in .NET Learn to create PDFs efficiently using C# PDFWriter with this step-by-step guide for developers. Read the article to enhance your skills today! 더 읽어보기