IRONPDF 사용 HTML to PDF Converter C# Open Source (.NET Libraries Comparison) 커티스 차우 업데이트됨:6월 22, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 Converting HTML to PDF is a common requirement in many software applications, such as generating reports, invoices, or saving web pages as PDFs. In this article, we'll explore three popular open-source libraries for HTML to PDF conversion in C#, review their strengths and limitations, and discuss why IronPDF is a better alternative in numerous instances. HTML to PDF converter C# open source 1. PuppeteerSharp PuppeteerSharp is a .NET wrapper for Puppeteer, a headless Chromium browser. It enables developers to convert HTML documents to PDFs by leveraging the Chromium rendering engine. PuppeteerSharp provides precise control over the rendering process. Here's an example: using PuppeteerSharp; using System.Threading.Tasks; class Program { static async Task Main(string[] args) { // Download Chromium to ensure compatibility with PuppeteerSharp await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision); // Launch a headless instance of Chromium browser using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true })) { // Open a new browser page var page = await browser.NewPageAsync(); // Set the HTML content for the page await page.SetContentAsync("<html><body><h1>Hello, PuppeteerSharp!</h1></body></html>"); // Generate a PDF from the rendered HTML content await page.PdfAsync("output.pdf"); Console.WriteLine("PDF Generated Successfully!"); } } } using PuppeteerSharp; using System.Threading.Tasks; class Program { static async Task Main(string[] args) { // Download Chromium to ensure compatibility with PuppeteerSharp await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision); // Launch a headless instance of Chromium browser using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true })) { // Open a new browser page var page = await browser.NewPageAsync(); // Set the HTML content for the page await page.SetContentAsync("<html><body><h1>Hello, PuppeteerSharp!</h1></body></html>"); // Generate a PDF from the rendered HTML content await page.PdfAsync("output.pdf"); Console.WriteLine("PDF Generated Successfully!"); } } } $vbLabelText $csharpLabel Code Explanation Download Chromium: PuppeteerSharp automatically downloads the required Chromium version to ensure compatibility. Launch Browser: Start a headless instance of Chromium using Puppeteer.LaunchAsync(). Set HTML Content: Load the desired HTML into the browser page using page.SetContentAsync(). Generate PDF: Use the page.PdfAsync() method to generate a PDF of the rendered content. The result is a high-quality PDF (output.pdf) that accurately replicates the HTML structure and design. Pros High Fidelity Rendering: Supports modern web technologies, including advanced CSS and JavaScript. Automation Capabilities: Besides PDFs, PuppeteerSharp can automate web browsing, testing, and data extraction. Active Development: PuppeteerSharp is actively maintained and regularly updated. Cons Large File Size: Requires downloading and bundling the Chromium browser, increasing deployment size. Resource Intensive: Running a browser instance can be heavy on system resources, especially for large-scale applications. Limited PDF-Specific Features: PuppeteerSharp focuses on rendering rather than enhancing PDFs (e.g., adding headers or footers). 2. PdfSharp PdfSharp is a powerful open-source library for creating and manipulating PDF files in C#. While it doesn't directly support HTML rendering, it excels at providing developers with tools to generate and edit PDF documents programmatically. Key Features of PdfSharp PDF Creation: PdfSharp allows developers to generate new PDF files from scratch by defining page sizes, adding text, shapes, images, and more. Manipulation of Existing PDFs: You can modify existing PDF documents, such as merging, splitting, or extracting content. Drawing Capabilities: PdfSharp provides robust graphics capabilities for adding custom designs to PDF files using the XGraphics class. Lightweight: It is a lightweight library, making it ideal for projects where simplicity and speed are priorities. using PdfSharp.Pdf; using PdfSharp.Drawing; using HtmlAgilityPack; class Program { static void Main(string[] args) { // Example HTML content string htmlContent = "<html><body><h1>Hello, PdfSharp!</h1><p>This is an example of HTML to PDF.</p></body></html>"; // Parse HTML using HtmlAgilityPack (You need to add HtmlAgilityPack via NuGet) var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlContent); // Create a new PDF document PdfDocument pdfDocument = new PdfDocument { Info = { Title = "HTML to PDF Example" } }; // Add a new page to the document PdfPage page = pdfDocument.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont titleFont = new XFont("Arial", 20, XFontStyle.Bold); XFont textFont = new XFont("Arial", 12, XFontStyle.Regular); // Draw the parsed HTML content int yPosition = 50; // Starting Y position foreach (var node in htmlDoc.DocumentNode.SelectNodes("//h1 | //p")) { if (node.Name == "h1") { gfx.DrawString(node.InnerText, titleFont, XBrushes.Black, new XRect(50, yPosition, page.Width - 100, page.Height - 100), XStringFormats.TopLeft); yPosition += 30; // Adjust spacing } else if (node.Name == "p") { gfx.DrawString(node.InnerText, textFont, XBrushes.Black, new XRect(50, yPosition, page.Width - 100, page.Height - 100), XStringFormats.TopLeft); yPosition += 20; // Adjust spacing } } // Save the PDF document string outputFilePath = "HtmlToPdf.pdf"; pdfDocument.Save(outputFilePath); System.Console.WriteLine($"PDF file created: {outputFilePath}"); } } using PdfSharp.Pdf; using PdfSharp.Drawing; using HtmlAgilityPack; class Program { static void Main(string[] args) { // Example HTML content string htmlContent = "<html><body><h1>Hello, PdfSharp!</h1><p>This is an example of HTML to PDF.</p></body></html>"; // Parse HTML using HtmlAgilityPack (You need to add HtmlAgilityPack via NuGet) var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlContent); // Create a new PDF document PdfDocument pdfDocument = new PdfDocument { Info = { Title = "HTML to PDF Example" } }; // Add a new page to the document PdfPage page = pdfDocument.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont titleFont = new XFont("Arial", 20, XFontStyle.Bold); XFont textFont = new XFont("Arial", 12, XFontStyle.Regular); // Draw the parsed HTML content int yPosition = 50; // Starting Y position foreach (var node in htmlDoc.DocumentNode.SelectNodes("//h1 | //p")) { if (node.Name == "h1") { gfx.DrawString(node.InnerText, titleFont, XBrushes.Black, new XRect(50, yPosition, page.Width - 100, page.Height - 100), XStringFormats.TopLeft); yPosition += 30; // Adjust spacing } else if (node.Name == "p") { gfx.DrawString(node.InnerText, textFont, XBrushes.Black, new XRect(50, yPosition, page.Width - 100, page.Height - 100), XStringFormats.TopLeft); yPosition += 20; // Adjust spacing } } // Save the PDF document string outputFilePath = "HtmlToPdf.pdf"; pdfDocument.Save(outputFilePath); System.Console.WriteLine($"PDF file created: {outputFilePath}"); } } $vbLabelText $csharpLabel Code Explanation HTML Parsing: The example uses HtmlAgilityPack (an open-source library for parsing and manipulating HTML) to extract text content from <h1> and <p> tags. Drawing Content: PdfSharp's XGraphics class is used to render the parsed HTML content as text on a PDF page. Limitations: This approach works for simple HTML structures but won't handle complex layouts, styles, or JavaScript. Pros and Cons of PdfSharp Pros Lightweight and Easy to Use: PdfSharp is intuitive and straightforward, making it ideal for developers starting with PDF generation. Open-Source and Free: No licensing fees, and the source code is available for customization. Custom Drawing: Provides excellent capabilities for creating PDFs from scratch with custom designs. Cons No HTML to PDF Conversion: PdfSharp does not natively support rendering HTML to PDF, requiring additional libraries for parsing HTML. Limited Support for Modern Features: Does not provide advanced capabilities like interactive PDFs, digital signatures, or annotations. Performance Constraints: May not be as optimized as professional libraries for large-scale or enterprise applications. 3. Pdfium.NET SDK Pdfium.NET is a comprehensive library based on the open-source PDFium project, designed for viewing, editing, and manipulating PDF files in .NET applications. It provides developers with powerful tools to create, edit, and extract content from PDFs, making it suitable for a wide range of use cases. It is basically a free HTML to PDF converter library. Key Features of Pdfium.NET SDK PDF Creation and Editing: Generate PDFs from scratch or from scanned images. Edit existing PDFs by adding text, images, or annotations. Text and Image Extraction: Extract text and images from PDF file format documents for further processing. Search for specific text within a PDF document. PDF Viewer Control: Embed a standalone PDF viewer in WinForms or WPF applications. Supports zooming, scrolling, bookmarks, and text search. Compatibility: Works with .NET Framework, .NET Core, .NET Standard, and .NET 6+. Compatible with Windows and macOS platforms. Advanced Features: Merge and split PDF files. Render PDFs as images for display or printing. using Pdfium.Net.SDK; using System; class Program { static void Main(string[] args) { // Initialize Pdfium.NET SDK functionalities PdfCommon.Initialize(); // Create a new PDF document PdfDocument pdfDocument = PdfDocument.CreateNew(); // Add a page to the document (A4 size in points: 8.27 x 11.69 inches) var page = pdfDocument.Pages.InsertPageAt(pdfDocument.Pages.Count, 595, 842); // Sample HTML content to be parsed and rendered manually var htmlContent = "<h1>Hello, Pdfium.NET SDK!</h1><p>This is an example of HTML to PDF.</p>"; // Example: Manually render text since Pdfium.NET doesn't render HTML directly var font = PdfFont.CreateFont(pdfDocument, "Arial"); page.AddText(72, 750, font, 20, "Hello, Pdfium.NET SDK!"); page.AddText(72, 700, font, 14, "This is an example of HTML to PDF."); // Save the document to a file string outputFilePath = "HtmlToPdfExample.pdf"; pdfDocument.Save(outputFilePath, SaveFlags.Default); Console.WriteLine($"PDF created successfully: {outputFilePath}"); } } using Pdfium.Net.SDK; using System; class Program { static void Main(string[] args) { // Initialize Pdfium.NET SDK functionalities PdfCommon.Initialize(); // Create a new PDF document PdfDocument pdfDocument = PdfDocument.CreateNew(); // Add a page to the document (A4 size in points: 8.27 x 11.69 inches) var page = pdfDocument.Pages.InsertPageAt(pdfDocument.Pages.Count, 595, 842); // Sample HTML content to be parsed and rendered manually var htmlContent = "<h1>Hello, Pdfium.NET SDK!</h1><p>This is an example of HTML to PDF.</p>"; // Example: Manually render text since Pdfium.NET doesn't render HTML directly var font = PdfFont.CreateFont(pdfDocument, "Arial"); page.AddText(72, 750, font, 20, "Hello, Pdfium.NET SDK!"); page.AddText(72, 700, font, 14, "This is an example of HTML to PDF."); // Save the document to a file string outputFilePath = "HtmlToPdfExample.pdf"; pdfDocument.Save(outputFilePath, SaveFlags.Default); Console.WriteLine($"PDF created successfully: {outputFilePath}"); } } $vbLabelText $csharpLabel Code Explanation SDK Initialization: The PdfCommon.Initialize() method initializes Pdfium.NET functionalities. Creating a PDF: A new PDF document is created using PdfDocument.CreateNew(). Adding Pages: Pages are inserted into the PDF with specified dimensions (e.g., A4 size). Rendering HTML Content: Since Pdfium.NET SDK does not natively support HTML rendering, you need to manually parse and render HTML elements as text, shapes, or images. Saving the PDF: The document is saved to a file path with the Save() method. Pros Allows full control over PDF creation and editing. Flexible for drawing and adding text, images, and shapes. Powerful capabilities for viewing and manipulating PDFs in desktop applications. Cons Does not directly convert HTML to PDF. Parsing and rendering HTML manually can be complex and time-consuming. Best suited for applications focusing on PDF editing and manipulation rather than HTML conversion. Introducing IronPDF IronPDF is a professional-grade library designed for .NET developers to effortlessly convert HTML content into high-quality PDFs. Known for its reliability, advanced features, and ease of use, IronPDF streamlines the development process while delivering precise rendering and robust functionality. Here’s why IronPDF is a standout solution: Key Features Direct HTML to PDF Conversion: Create PDF documents directly using IronPDF with HTML content, including CSS and JavaScript, into fully formatted PDFs. With just a few lines of code, developers can generate PDFs from web pages, raw HTML strings, or local HTML files. Modern Rendering Capabilities: Supporting the latest web standards, IronPDF ensures accurate rendering of complex layouts, styles, and interactive elements to convert HTML pages to PDF. Advanced PDF Features: IronPDF offers extensive customization options, such as adding headers, footers, watermarks, annotations, and bookmarks. It also supports merging, splitting, and editing existing PDFs. Performance and Scalability: Optimized for both small-scale applications and enterprise environments, IronPDF delivers fast, reliable performance for projects of any size. Ease of Integration: Designed for .NET Framework and .NET Core, IronPDF integrates smoothly with C# applications, offering developers a straightforward setup process and comprehensive documentation. Why Choose IronPDF? IronPDF stands out among other solutions due to its combination of features, developer support, and performance. Unlike open-source alternatives that often require extensive configuration or external dependencies, IronPDF is a self-contained solution that simplifies development without sacrificing functionality. Whether it's for generating invoices, reports, or archiving web content, IronPDF empowers developers with the tools they need to achieve professional-grade results quickly and efficiently. IronPDF is a practical choice for developers who value reliability, scalability, and ease of use in their HTML to PDF workflows. How to convert HTML to PDF using IronPDF using IronPdf; class Program { static void Main() { // Specify license key IronPdf.License.LicenseKey = "Your Key"; // Create a new HtmlToPdf object using ChromePdfRenderer var Renderer = new ChromePdfRenderer(); // Define the HTML string to be converted string htmlContent = "<html><body><h1>IronPDF: Better than Open source</h1></body></html>"; // Convert the HTML string to a PDF document var document = Renderer.RenderHtmlAsPdf(htmlContent); // Save the PDF document to a file document.SaveAs("html2Pdf.pdf"); Console.WriteLine("PDF generated and saved successfully!"); } } using IronPdf; class Program { static void Main() { // Specify license key IronPdf.License.LicenseKey = "Your Key"; // Create a new HtmlToPdf object using ChromePdfRenderer var Renderer = new ChromePdfRenderer(); // Define the HTML string to be converted string htmlContent = "<html><body><h1>IronPDF: Better than Open source</h1></body></html>"; // Convert the HTML string to a PDF document var document = Renderer.RenderHtmlAsPdf(htmlContent); // Save the PDF document to a file document.SaveAs("html2Pdf.pdf"); Console.WriteLine("PDF generated and saved successfully!"); } } $vbLabelText $csharpLabel Code Snippet Explanation License Key Setup: The program starts by setting the IronPDF license key, which is required to unlock the full functionality of the library. Creating the Renderer: An instance of ChromePdfRenderer is initialized. This component is responsible for converting HTML content into a PDF document, acting as a bridge between the raw HTML and the final output. Defining HTML Content: A string variable, htmlContent, is created to store the HTML structure that will be converted into a PDF. In this example, it contains a simple heading. Converting HTML to PDF: The RenderHtmlAsPdf() method is called on the ChromePdfRenderer instance, passing the HTML string as input. This function processes the content and transforms it into a PDF document. Saving the PDF: Finally, the generated PDF is saved to a file named "html2Pdf.pdf" using the SaveAs() method, storing it on the disk for future access. Output PDF License Information (Trial Available) IronPDF requires a valid license key for full functionality. You can obtain a trial license from the official website. Before using the IronPDF library, set the license key as follows: IronPdf.License.LicenseKey = "your key"; IronPdf.License.LicenseKey = "your key"; $vbLabelText $csharpLabel This ensures that the library operates without limitations. Conclusion PuppeteerSharp is an excellent choice for developers who need precise rendering of HTML to PDF, especially when dealing with complex web pages. However, for applications that require advanced PDF-specific features, performance optimization, and ease of integration, professional tools like IronPDF are often the better option. PdfSharp is a great choice for lightweight, programmatic PDF creation and manipulation, especially for projects with simple requirements. However, if your application requires converting HTML to PDF or advanced PDF features, IronPDF provides a more efficient and feature-rich solution. While Pdfium.NET SDK is a robust tool for PDF manipulation, IronPDF provides native support for direct HTML-to-PDF conversion, including rendering modern HTML, CSS, and JavaScript. IronPDF simplifies the workflow with built-in methods like HtmlToPdf.RenderHtmlAsPdf(), making it faster and more efficient for developers. Whether it's for generating invoices, reports, or archiving web content, IronPDF empowers developers with the tools they need to achieve professional-grade results quickly and efficiently. IronPDF is a practical choice for developers who value reliability, scalability, and ease of use in their HTML to PDF workflows. 자주 묻는 질문 C#에서 HTML을 PDF로 변환하려면 어떻게 해야 하나요? IronPDF의 RenderHtmlAsPdf 메서드를 사용하여 HTML 문자열을 PDF로 변환할 수 있습니다. 또한 IronPDF는 RenderHtmlFileAsPdf 메서드를 사용하여 HTML 파일을 PDF로 직접 변환하는 기능도 지원합니다. PDF 변환을 위해 오픈 소스 라이브러리보다 IronPDF를 사용하면 어떤 이점이 있나요? IronPDF는 최신 웹 표준, 고급 PDF 기능, .NET 애플리케이션과의 간편한 통합을 지원하여 HTML을 PDF로 직접 변환할 수 있습니다. PuppeteerSharp, PdfSharp, Pdfium.NET SDK와 같은 오픈 소스 대안에 비해 전문적인 솔루션을 제공합니다. IronPDF는 PDF 변환 중에 복잡한 HTML, CSS 및 JavaScript를 처리할 수 있나요? 예, IronPDF는 최신 웹 표준을 지원하므로 HTML을 PDF로 변환하는 동안 복잡한 레이아웃, 스타일 및 대화형 요소를 정확하게 렌더링할 수 있습니다. HTML을 PDF로 변환하는 데 IronPDF를 사용하려면 무엇이 필요하나요? IronPDF를 사용하려면 유효한 라이선스 키가 필요합니다. 개발자는 공식 웹사이트에서 평가판 라이선스를 받으면 모든 기능을 사용할 수 있습니다. IronPDF가 개발자에게 실용적인 선택인 이유는 무엇인가요? IronPDF는 안정성, 확장성, 사용 편의성, HTML에서 PDF로의 변환을 위한 강력한 기능으로 실용적입니다. 전문가 수준의 PDF를 효율적이고 효과적으로 생성하는 데 이상적입니다. PDF 생성에 PuppeteerSharp를 사용할 때 어떤 제한 사항이 있나요? PuppeteerSharp를 사용하려면 Chromium 브라우저를 다운로드하고 번들로 제공해야 하므로 파일 크기가 커지고 리소스 집약적일 수 있습니다. 추가 기능으로 PDF를 향상시키기보다는 렌더링에 중점을 둡니다. Pdfium.NET SDK는 HTML에서 PDF로 변환하는 측면에서 IronPDF와 어떻게 다른가요? Pdfium.NET SDK는 기본적으로 HTML에서 PDF로의 변환을 지원하지 않으므로 HTML 요소를 수동으로 렌더링해야 합니다. 이에 반해 IronPDF는 직접 변환을 위한 내장 메서드를 제공하여 프로세스를 간소화합니다. PdfSharp는 복잡한 HTML 구조를 PDF로 렌더링하는 데 적합합니까? PdfSharp는 기본적으로 HTML에서 PDF로의 변환을 지원하지 않으며 복잡한 레이아웃, 스타일 또는 JavaScript로 인해 어려움을 겪을 수 있으므로 HTML 구문 분석을 위한 추가 라이브러리가 필요합니다. IronPDF는 PDF 조작을 위해 어떤 기능을 제공하나요? IronPDF는 PDF에서 콘텐츠를 생성, 편집 및 추출할 수 있는 도구를 제공합니다. HTML에서 PDF로의 직접 변환, 텍스트/이미지 추출, 애플리케이션에 PDF 뷰어 임베딩을 지원합니다. IronPDF는 .NET 10과 호환되며, .NET 10 프로젝트에서 사용하면 어떤 이점이 있나요? 예 - IronPDF는 .NET 10과 완벽하게 호환됩니다. 특별한 해결 방법 없이 .NET 10 프로젝트를 지원하며 배열 인터페이스 메서드 가상화, 향상된 성능 및 메모리 사용량 감소와 같은 런타임 개선 사항을 활용합니다. .NET 10에서 HTML-PDF 변환을 위해 IronPDF는 어떤 새로운 기능을 제공하나요? .NET 10에서 IronPDF는 최신 릴리스부터 '제로 데이' 지원을 제공하여 새로운 런타임과 완벽한 호환성을 제공합니다. 개발자는 .NET 10 렌더링 및 JIT 엔진의 개선된 기능 덕분에 더 빠른 시작 시간, 향상된 메모리 사용량, 향상된 렌더링 성능을 경험할 수 있습니다. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, 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! 더 읽어보기 IronPDF Live Coding Recap: Pixel-Perfect PDFs in Real-World .NET ProjectsHow to Convert HTML to PDF C# Witho...
업데이트됨 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! 더 읽어보기