IRONPDF 사용 C# Create PDF File Programmatically 커티스 차우 업데이트됨:8월 31, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 For developers, there are many scenarios where the need arises to create PDF files programmatically. You may need to generate PDF reports and other PDF files programmatically in your software. It would be long, expensive, and inefficient to write your code and functions from scratch. This is where IronPDF comes in. Although creating PDF files programmatically in .NET can be frustrating, thankfully, there is now a solution that makes it so much more manageable. Topics Covered In Tutorial We will cover the following topics in this tutorial: Steps to create PDF files programmatically Step 1: Create a C# Project Step 2: Install the IronPdf Library Method 1: NuGet Package Manager Method 2: NuGet Package Manager Console Method 3: Using DLL file Step 3: Add the IronPdf Namespace Step 4: Create a PDF document programmatically 4.1: Create a PDF document programmatically using HTML String 4.2: Create a PDF document programmatically using HTML files 4.3: Create a PDF document programmatically using URL 4.4: Create a PDF document programmatically with formatting Summary IronPDF IronPDF is a C# PDF library for .NET developers that provides a set of classes used to create PDF files programmatically. These classes are located in the IronPdf assembly and are designed to be easy to use with any .NET language, including C#, VB.NET, F#, etc. The library offers many functions for creating PDF documents, manipulating existing PDFs, and reading PDFs. The current version of the IronPDF library supports the following features: Reading and writing of encrypted, compressed, and uncompressed files. Creating new PDF files from scratch or by parsing existing document streams. Applying custom transformations to pages in a document stream before being written to disk as a new file. Encrypting and decrypting PDF files. Merging existing PDF files seamlessly. Creating and editing interactive PDF forms. Extracting text from a page or document effectively and many other unique features. Let's start with how we can use the IronPDF library to create PDFs programmatically in C#. Steps to Create PDF Files Programmatically This article will use the Console Application template for this demonstration. You can use any, according to your requirements and choice. You may also use your existing project in which you wish to add a PDF file-generating tool. Step 1: Create a C# Project This tutorial will use Visual Studio and the C# programming language to build our project. You should have basic knowledge of HTML and the C# language. It is also recommended that you familiarize yourself with Visual Studio. Let's look at the multiple methods for creating PDF files programmatically using the IronPDF C# library. Let's begin by creating a C# project. Open Visual Studio. Create a new C# Project or open an existing project. Give a name to the project. Select .Net Core >= 3.1 because 3.1 is supported and works on every device. Recommend the latest version of .Net Core. Let's move now to Step 2. Step 2: Install the IronPDF Library Before proceeding further, we should install the IronPdf library in our project. We can do this in various ways. Method 1: NuGet Package Manager We can install the IronPdf C# Library from the NuGet Package Manager. Open the NuGet Package Manager by clicking on Tools > NuGet Package Manager > Manage NuGet Packages for Solution. This will open the NuGet Package Manager Solution Explorer. Open NuGet Package Manager Click on "Browse" and write IronPdf in the search bar. The following result will appear. Select IronPdf and click the Install button; the library will begin installing. Search and install IronPdf package Method 2: NuGet Package Manager Console We can use the NuGet Package Manager Console to install our library quickly. It does not require any administrative privileges to install. You can use a NuGet command to install the IronPdf library in your project. Install-Package IronPdf Install IronPdf package via Commandline Method 3: Using a DLL file The third way to use IronPDF in your project is to add a DLL file from the IronPDF library. You can download the DLL file. Download the DLL zip file. Extract it to a specific folder. Open a project in Visual Studio. In the Solution Explorer, right-click on References and browse for the IronPDF DLL file. Visit a more detailed installation guide on how to install IronPDF. Step 3: Add the IronPdf Namespace Now add the IronPdf namespace to your program. You need to add the given line of code at the top of the code files you wish to use IronPDF in. using IronPdf; using IronPdf; $vbLabelText $csharpLabel This will enable you to access the functions of IronPDF. You must add this line of code to every file where you wish to use the IronPDF features. Step 4: Create PDF Documents Programmatically We will look at multiple methods to create PDFs using IronPDF. We will see how easy it is to use simple functions to create PDF files. Let's get started with creating PDFs using HTML string. 4.1. Create PDFs Programmatically using HTML String In the IronPDF library, HTML is used for styling purposes. You must have basic knowledge of the HTML language to generate PDF documents using the IronPDF library. The IronPDF library makes it very easy to process HTML strings and convert them into PDF format. Let's look at how to do it using code. using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // HTML content to be converted into a PDF string htmlString = "<h1> Generated PDF File!</h1> <p> This file is generated by IronPDF library from HTML String!</p> <p>It is a great Library to manipulate PDF Files.</p>"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert the HTML string to a PDF and save it renderer.RenderHtmlAsPdf(htmlString).SaveAs("PDF from HTML String.pdf"); using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // HTML content to be converted into a PDF string htmlString = "<h1> Generated PDF File!</h1> <p> This file is generated by IronPDF library from HTML String!</p> <p>It is a great Library to manipulate PDF Files.</p>"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert the HTML string to a PDF and save it renderer.RenderHtmlAsPdf(htmlString).SaveAs("PDF from HTML String.pdf"); $vbLabelText $csharpLabel This code will generate a PDF file containing the content stored in the htmlString variable. In this code sample, the RenderHtmlAsPdf function has been used. This function performs the conversion of HTML String to a PDF document. You must be familiar with HTML tags to generate PDF files using the IronPDF library. The SaveAs function is used to save the output PDF file. You can see the output PDF file below. Output: PDF file output 4.2. Create PDFs Programmatically using HTML Files The IronPDF library provides a fantastic feature to create a PDF file from an HTML file. IronPDF directly converts everything in an HTML file, including images, CSS, forms, etc. to a PDF document. It does not require any other library or function for further processing. IronPDF directly converts any HTML file to a PDF file. Let's look at some sample code for creating a PDF file from an HTML file: using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert an HTML file to a PDF and save it var pdf = renderer.RenderHtmlFileAsPdf("IronFile.html").SaveAs("IronPDF file.pdf"); using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert an HTML file to a PDF and save it var pdf = renderer.RenderHtmlFileAsPdf("IronFile.html").SaveAs("IronPDF file.pdf"); $vbLabelText $csharpLabel We use the RenderHtmlFileAsPdf function to create PDFs from HTML files. You can give the HTML File location in the function parameter or put the HTML file in the bin folder of the source code, so you will only need to put the file name with extension in the RenderHtmlFileAsPdf function's parameter. The output PDF file will be saved in the bin folder when you run this code. The SaveAs function helps save created PDF files. 4.3. Create PDFs Programmatically using URLs Sometimes we need to create PDF files of a URL programmatically in our program. This can be a very technical task if we code everything from scratch. IronPDF helps us here by providing an excellent function for creating PDFs from URLs. You can use any URL to create a PDF. Let's examine how to do it: using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert a URL to a PDF and save it var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/blog/using-ironpdf/csharp-generate-pdf-tutorial/").SaveAs("IronPDF Generate PDF.pdf"); using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer var renderer = new ChromePdfRenderer(); // Convert a URL to a PDF and save it var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/blog/using-ironpdf/csharp-generate-pdf-tutorial/").SaveAs("IronPDF Generate PDF.pdf"); $vbLabelText $csharpLabel The above code will create a PDF of the given URL parameter to the RenderUrlAsPdf function. This function creates a PDF of the URL. This would otherwise be a very complex task if you attempted to do it from scratch, so IronPDF provides developers with a simple process to convert any URL to a PDF. The SaveAs function is used for saving output files in the bin folder. To set the file format to PDF, you must specify a .pdf extension with a file name parameter in the SaveAs function. You can see the bin folder in your project folder. The output is displayed below. Output: Create PDF file from URL 4.4. Create PDFs Programmatically using ASP.NET Web Forms ASP.NET is a server-side programming framework that extends the functionality of HTML and supports web development in a browser. ASP.NET pages are written in HTML, CSS, and JavaScript, and can be coded as ASPX files (.aspx). ASP.NET web forms create user-friendly, functionality-rich websites, online banking, intranets, and accounting systems. We will use the IronPDF library to convert ASP.NET web forms to PDF. Initially rendered as a web page, we will transform this into a PDF to view and download in a web browser. We will use the AspxToPdf class of IronPDF to complete the conversion. Let's see how to do it: Create an ASP.NET web form project in Visual Studio. The latest version of Visual Studio is recommended. Install the IronPDF library using the NuGet Package Manager or the DLL file according to your choice. You can also use the NuGet Package Manager Console to install it. Now, open any ASPX web page's code that you want to convert into a PDF file. Here we will create a PDF of the Default.aspx page of the project. Web Form project structure in Visual Studio Open the Default.aspx.cs file. Add the IronPdf namespace to the file, which is the most important line. using IronPdf; using IronPdf; $vbLabelText $csharpLabel Write the following line of code in the Page_Load function to create a PDF document of the page. AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser); AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser); $vbLabelText $csharpLabel And that's it! A PDF file of the ASPX webpage has been created. When you run the project, you will see a PDF of the web page in the browser. The result is the same as when you make a PDF by pressing Ctrl+P. Here you didn't need to press Ctrl+P to create a PDF of the ASPX file. This has been done on the server-side. In this code, we use the AspxToPdf class of IronPDF. The RenderThisPageAsPdf function creates the PDF of the ASPX webpage. The above code shows the PDF file in the browser. We can download the PDF file directly to our system by adding the following line of code in the Page_Load function: AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment); AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment); $vbLabelText $csharpLabel This code will download the PDF file of the ASPX web page in the system. We can also set the name of the ASPX PDF file. There are multiple options available for modifications and formatting, such as headers, footers, printing options, quality, etc. For more details, visit this comprehensive ASPX to PDF tutorial. Output: Output of rendering a PDF file from server-side Explore the latest Microsoft technology for Blazor application to create PDF files 4.5. Create PDFs Programmatically with Formatting When creating PDFs, most problems are encountered during the formatting of PDF documents. It isn't easy to format PDFs programmatically. But, we now have a solution in the shape of IronPDF. IronPDF assists with various formatting options to allow us to customize the PDF file we are creating. It provides us with methods to add headers, footers, margins, and many other formatting options. Using IronPDF enables us to set page orientation, page size, and titles. It also supports the changing of font size, font color, font type, and other font-related operations. You can add footers and headers with a divider line and custom text. Let's look at how to customize PDF files using IronPDF. Create a C# console project. You can create a GUI project, too, depending on your requirements. You can also open existing projects. Install the IronPDF library using NuGet Package Manager or the DLL file. Add the IronPDF namespace on top of the code file. Our setup of the application is now completed. Next, add the following code to the PDF file: using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer ChromePdfRenderer renderer = new IronPdf.ChromePdfRenderer(); // Configure rendering options renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait; renderer.RenderingOptions.SetCustomPaperSizeInInches(14, 40); renderer.RenderingOptions.PrintHtmlBackgrounds = true; renderer.RenderingOptions.Title = "PDF Generated"; renderer.RenderingOptions.Zoom = 100; // Margin Settings renderer.RenderingOptions.MarginTop = 40; renderer.RenderingOptions.MarginLeft = 20; renderer.RenderingOptions.MarginRight = 20; renderer.RenderingOptions.MarginBottom = 40; renderer.RenderingOptions.FirstPageNumber = 1; // Header Settings renderer.RenderingOptions.TextHeader.DrawDividerLine = true; renderer.RenderingOptions.TextHeader.CenterText = "Header!"; renderer.RenderingOptions.TextHeader.Font = IronSoftware.Drawing.FontTypes.Helvetica; // Footer Settings renderer.RenderingOptions.TextFooter.DrawDividerLine = true; renderer.RenderingOptions.TextFooter.Font = IronSoftware.Drawing.FontTypes.Arial; renderer.RenderingOptions.TextFooter.FontSize = 10; renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"; renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"; // HTML content to be converted into a PDF string htmlStr = "<h1>PDF Formatting!</h1><h3>Functions and properties for formatting </h3> <p>IronPDF is the best ever library for PDF operations and formatting. </p>"; // Convert the HTML string to a PDF and save it renderer.RenderHtmlAsPdf(htmlStr).SaveAs("PDF-Formatted.pdf"); using IronPdf; IronPdf.License.LicenseKey = "YourLicenseKey"; // Create a PDF renderer ChromePdfRenderer renderer = new IronPdf.ChromePdfRenderer(); // Configure rendering options renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait; renderer.RenderingOptions.SetCustomPaperSizeInInches(14, 40); renderer.RenderingOptions.PrintHtmlBackgrounds = true; renderer.RenderingOptions.Title = "PDF Generated"; renderer.RenderingOptions.Zoom = 100; // Margin Settings renderer.RenderingOptions.MarginTop = 40; renderer.RenderingOptions.MarginLeft = 20; renderer.RenderingOptions.MarginRight = 20; renderer.RenderingOptions.MarginBottom = 40; renderer.RenderingOptions.FirstPageNumber = 1; // Header Settings renderer.RenderingOptions.TextHeader.DrawDividerLine = true; renderer.RenderingOptions.TextHeader.CenterText = "Header!"; renderer.RenderingOptions.TextHeader.Font = IronSoftware.Drawing.FontTypes.Helvetica; // Footer Settings renderer.RenderingOptions.TextFooter.DrawDividerLine = true; renderer.RenderingOptions.TextFooter.Font = IronSoftware.Drawing.FontTypes.Arial; renderer.RenderingOptions.TextFooter.FontSize = 10; renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"; renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"; // HTML content to be converted into a PDF string htmlStr = "<h1>PDF Formatting!</h1><h3>Functions and properties for formatting </h3> <p>IronPDF is the best ever library for PDF operations and formatting. </p>"; // Convert the HTML string to a PDF and save it renderer.RenderHtmlAsPdf(htmlStr).SaveAs("PDF-Formatted.pdf"); $vbLabelText $csharpLabel This piece of code is formatting the PDF files. RenderingOptions is the primary tool to set different properties while creating PDF documents. renderer.RenderingOptions.TextHeader This line of code is used to set up the PDF file's header. You can access more properties for the header with this line of code. renderer.RenderingOptions.TextFooter This line of code sets up the footer properties such as text, right and left side of the footer, font size, and many others. renderer.RenderingOptions.PaperOrientation This line of code enables the user to set the page orientation (landscape or portrait) of the PDF file. renderer.RenderingOptions.Title We can use this line to set the title of the PDF file. In the last lines, we use the RenderHtmlAsPdf function to create a PDF of an HTML String, but we can use an HTML file to seamlessly convert it into PDF while preserving the current formatting. This is a very handy feature of IronPDF that gives you complete freedom to customize everything to do with PDF documents. Output: PDF output with formatting support Summary This tutorial shows how we can create PDFs programmatically using the IronPDF C# library. We have seen how to create PDF files from HTML String, HTML files, URLs, and ASP.NET web forms. The manipulation and formatting of PDF files become very easy with the IronPDF library function. All that is required is just a few lines of code to create and format the PDF file programmatically. IronPDF is ideal for developers and companies who need to manipulate PDF files within their software. You can try the free version to test it out, and there is a free trial key available that doesn't require any credit card payments. Further, the current special offer allows you to get five products by IronPDF for the price of just two lite licenses. 자주 묻는 질문 C#에서 프로그래밍 방식으로 PDF 파일을 만들려면 어떻게 해야 하나요? IronPDF 라이브러리를 사용하여 C#에서 프로그래밍 방식으로 PDF 파일을 만들 수 있습니다. 먼저 Visual Studio에서 C# 프로젝트를 설정하고 NuGet 패키지 관리자를 통해 IronPDF를 설치한 다음 IronPDF 네임스페이스를 추가합니다. 그런 다음 해당 메서드를 사용하여 HTML 문자열, HTML 파일 또는 URL과 같은 소스에서 PDF를 생성할 수 있습니다. .NET 프로젝트에 PDF 라이브러리를 설치하는 단계는 무엇인가요? .NET 프로젝트에 IronPDF와 같은 PDF 라이브러리를 설치하려면 Visual Studio의 NuGet 패키지 관리자를 사용하세요. 패키지 관리자 콘솔을 사용하거나 프로젝트에 직접 DLL 파일을 포함시켜 라이브러리의 기능을 추가할 수도 있습니다. C#을 사용하여 웹 페이지 URL을 PDF로 변환할 수 있나요? 예, IronPDF를 사용하면 RenderUrlAsPdf 기능을 활용하여 웹 페이지 URL을 PDF로 변환할 수 있습니다. 이를 통해 웹 콘텐츠를 PDF 문서로 쉽게 변환할 수 있습니다. C#에서 PDF 문서의 서식을 사용자 지정하려면 어떻게 해야 하나요? IronPDF는 PDF 서식을 사용자 지정할 수 있는 다양한 옵션을 제공합니다. 페이지 방향, 용지 크기를 설정하고 머리글과 바닥글을 추가할 수 있습니다. 또한 텍스트 속성을 사용자 지정하여 PDF가 특정 요구 사항을 충족하도록 할 수 있습니다. C#을 사용하여 여러 PDF 파일을 하나로 병합할 수 있나요? 예, IronPDF 라이브러리를 사용하면 여러 PDF 파일을 하나의 문서로 병합할 수 있습니다. 이 기능을 사용하면 서로 다른 PDF 문서를 프로그래밍 방식으로 쉽게 결합할 수 있습니다. .NET 애플리케이션의 HTML 콘텐츠에서 PDF를 생성하려면 어떻게 해야 하나요? IronPDF를 사용하면 HTML 문자열의 경우 RenderHtmlAsPdf 또는 HTML 파일의 경우 RenderHtmlFileAsPdf와 같은 함수를 사용하여 HTML 콘텐츠에서 PDF를 생성할 수 있어 HTML을 PDF로 변환하는 간단한 방법을 제공합니다. C# 라이브러리를 사용하여 PDF 파일을 암호화하고 해독할 수 있나요? 예, IronPDF는 PDF 파일의 암호화 및 암호 해독을 지원합니다. PDF 문서에 보안 설정을 적용하여 액세스 및 수정을 제어할 수 있습니다. .NET에서 프로그래밍 방식으로 PDF를 생성할 때 직면하는 일반적인 문제는 무엇인가요? 일반적인 문제로는 복잡한 레이아웃과 스타일 처리, 대용량 파일 관리, 다양한 시스템 간의 호환성 보장 등이 있습니다. IronPDF는 포괄적인 기능 세트와 사용 편의성으로 이러한 문제를 완화하는 데 도움이 됩니다. IronPDF는 PDF 생성 기능을 테스트할 수 있는 무료 평가판을 제공하나요? 예, IronPDF는 개발자가 초기 비용 없이 기능을 탐색하고 테스트할 수 있는 무료 평가판을 제공하므로 프로젝트에 대한 기능을 쉽게 평가할 수 있습니다. IronPDF는 .NET 10과 호환되며 이는 개발자에게 어떤 의미가 있나요? 예, IronPDF는 .NET 10(뿐만 아니라 버전 9, 8, 7, 6, 5, .NET Core 3.1+, .NET Standard 2.0+ 및 .NET Framework 4.6.2+)과 완벽하게 호환됩니다. 즉, 해결 방법 없이도 .NET 10 애플리케이션에서 HTML을 PDF로 렌더링, 병합/분할, 암호화, 디지털 서명 등 IronPDF의 모든 기능을 사용할 수 있습니다. 이 라이브러리는 런타임 성능 향상, 메모리 할당량 감소, 플랫폼에 도입된 최적화 등 .NET 10의 향상된 기능의 이점을 누릴 수 있습니다. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, 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! 더 읽어보기 C# 14 PDF Generator – A Comprehensive Guide (2025 Edition)How to Open a PDF File in C#
업데이트됨 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! 더 읽어보기