제품 비교 How to Add Page Numbers in PDF using iTextSharp in C# 커티스 차우 업데이트됨:12월 17, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 "Portable Document Format," or PDF, is a file format created by Adobe. PDFs come in handy when presenting documents that need to have their text and images formatted consistently. In the current world, PDF files are essential and are utilized for document creation and invoicing across all corporate sectors. Thanks to the several PDF libraries that are now on the market, creating PDFs has become practically instinctive. To choose the appropriate PDF library for you, it is crucial to weigh the benefits and characteristics of each before utilizing one for your project. In this article, we are going to see how to add page numbers in PDF using iTextSharp C#. Also, we are going to compare iTextSharp with IronPDF. How to Add Page Numbers in PDF using iTextSharp C# Create a new C# project using any IDE. Create a new PDF object. Add page numbers to the HTML footer. Create a PDF from HTML content. Save the PDF file to your computer. What is IronPDF IronPDF is a robust PDF .NET Framework that developers use to easily create, view, and edit PDFs. IronPDF is a sophisticated tool that runs on a chromium engine internally. It can convert HTML5, JavaScript, CSS, and image files to PDF, add custom Headers and Footers, and produce PDFs precisely as they appear in a browser. Many online and net formats, including HTML, ASPX, Razor View, and MVC, are supported by IronPDF. IronPDF Features Utilizing .NET C# code to create, read, and easily edit PDF files. Creating PDFs from a website URL link while managing User-Agents, Proxies, Cookies, HTTP headers, and form variables to enable login using HTML login forms. Extracting images from existing PDF files. Including elements in a PDF: table, text, images, bookmarks, watermarks, headers, footers, and more. Ability to split and combine pages from multiple PDF documents with ease. To know more about the IronPDF documentation, refer here. Installing IronPDF Within Visual Studio Tools, select the NuGet Package Manager, and you can find the Visual Command-Line interface under Tools. The command below should be entered into the package management terminal tab. Install-Package IronPdf Or we can use the Package manager method. Installing the package straight into the solution is possible with Visual Studio's NuGet Package Manager option. A search box is available for locating packages on the NuGet website. We only need to look for "IronPDF" in the package manager, as the screenshot below illustrates: The list of relevant search results is displayed in the image above. For the package to be installed on your system, please make the necessary selections. Now that the package has been downloaded and installed, it may be utilized in the current project. What is iTextSharp iTextSharp is a flexible library for producing and modifying PDF documents in C#. It offers several features, such as encryption, PDF merging, text and image extraction, and much more. iTextSharp is an efficient tool for numerous tasks, including adding page numbers to PDFs. iTextSharp Features An API to generate PDF documents is available through the iText library. Both HTML and XML strings may be parsed into PDF files using the iText program. We may add bookmarks, page numbers, and markers to our PDF documents using the iText library. We can also split a PDF document into several PDFs or merge multiple PDF documents into a single PDF using the iText library. We can modify PDF forms with iText. Install iTextSharp Use the NuGet package manager to search for iText. iText7 and iText.pdfhtml are required installations since iText functionalities are divided across many packages. Should you choose the Visual Command-Line interface, the following packages need to be installed: Install-Package iText7 Install-Package itext7.pdfhtml Install-Package iText7 Install-Package itext7.pdfhtml SHELL Since iText 7 is the most recent version, it is the one we are employing in our solution. Adding Page Numbers using IronPDF Adding page numbers to PDF files is made simple through IronPDF's comprehensive library. To illustrate, see the code below: using IronPdf; class Program { static void Main(string[] args) { // Initialize the IronPdf renderer var renderer = new IronPdf.HtmlToPdf(); // HTML content to convert to PDF string header = "<h1>Hello Ironpdf!</h1>"; // Render the HTML content to PDF PdfDocument pdf = renderer.RenderHtmlAsPdf(header); // Define the footer with page number placeholders HtmlHeaderFooter htmlFooter = new HtmlHeaderFooter { HtmlFragment = "<center><i>{page} of {total-pages}</i></center>" }; // Add footer to the PDF pdf.AddHtmlFooters(htmlFooter); // Save the output PDF file pdf.SaveAs("output.pdf"); } } using IronPdf; class Program { static void Main(string[] args) { // Initialize the IronPdf renderer var renderer = new IronPdf.HtmlToPdf(); // HTML content to convert to PDF string header = "<h1>Hello Ironpdf!</h1>"; // Render the HTML content to PDF PdfDocument pdf = renderer.RenderHtmlAsPdf(header); // Define the footer with page number placeholders HtmlHeaderFooter htmlFooter = new HtmlHeaderFooter { HtmlFragment = "<center><i>{page} of {total-pages}</i></center>" }; // Add footer to the PDF pdf.AddHtmlFooters(htmlFooter); // Save the output PDF file pdf.SaveAs("output.pdf"); } } $vbLabelText $csharpLabel Explanation Initialize the Renderer: We create an instance of HtmlToPdf, which provides the HTML-to-PDF conversion feature. Define HTML Content: The HTML content that needs to be converted to a PDF is specified. Render HTML Content: The RenderHtmlAsPdf function is used to convert the HTML to a PDF document. Define Footer: Page numbers are represented as placeholders in the HTML footer text. Add Footer and Save PDF: Apply the footer to the document and save it as a PDF file. To learn more about IronPDF code, refer here. Adding Page Numbers using iTextSharp First, let's use iTextSharp to generate a new PDF document. Here's a basic illustration of how to make a new PDF document with page numbers: using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { // Create a new PDF document Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("output.pdf", FileMode.Create)); // Open the document to add content document.Open(); document.Add(new Paragraph("Hello, world!")); // Attach page number event to PDF writer writer.PageEvent = new PageNumberEventHandler(); // Close the document document.Close(); } } public class PageNumberEventHandler : PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document document) { base.OnEndPage(writer, document); // Create a table for the page number PdfPTable table = new PdfPTable(1); table.TotalWidth = 300f; table.HorizontalAlignment = Element.ALIGN_CENTER; // Add page number to the table cell PdfPCell cell = new PdfPCell(new Phrase($"Page {writer.PageNumber}")); cell.Border = 0; table.AddCell(cell); // Write the table at the bottom of the page table.WriteSelectedRows(0, -1, 150, document.Bottom, writer.DirectContent); } } } using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { // Create a new PDF document Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("output.pdf", FileMode.Create)); // Open the document to add content document.Open(); document.Add(new Paragraph("Hello, world!")); // Attach page number event to PDF writer writer.PageEvent = new PageNumberEventHandler(); // Close the document document.Close(); } } public class PageNumberEventHandler : PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document document) { base.OnEndPage(writer, document); // Create a table for the page number PdfPTable table = new PdfPTable(1); table.TotalWidth = 300f; table.HorizontalAlignment = Element.ALIGN_CENTER; // Add page number to the table cell PdfPCell cell = new PdfPCell(new Phrase($"Page {writer.PageNumber}")); cell.Border = 0; table.AddCell(cell); // Write the table at the bottom of the page table.WriteSelectedRows(0, -1, 150, document.Bottom, writer.DirectContent); } } } $vbLabelText $csharpLabel Explanation Create PDF Document: Initialize a new Document and PdfWriter to produce an empty PDF file. Add Content: Add basic content such as paragraphs to the document. Page Numbering: We utilize iTextSharp's event handling to include page numbers. We create a custom class inheriting from PdfPageEventHelper. Override OnEndPage: In the custom class, override the OnEndPage method to add page numbers at the bottom of each page. Close Document: Finalize the document by closing it. Conclusion In summary, IronPDF's specialization, usability, and seamless integration with .NET environments position it as the best option for scenarios requiring HTML to PDF conversion and related functionalities, even though iTextSharp is still a strong competitor in the landscape of C# PDF manipulation libraries. With IronPDF, you can create invoices, reports, and dynamically generated documents from HTML content with the ease, effectiveness, and adaptability required to succeed in the modern development environment. A permanent license, upgrade options, and a year of software maintenance are all included in IronPDF's Lite edition. The watermarked trial period allows users to assess the product in practical settings. Visit the license page to learn more. For more details about Iron Software, visit their website. 참고해 주세요iTextSharp is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by iTextSharp. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing. 자주 묻는 질문 C#에서 iTextSharp를 사용하여 PDF에 페이지 번호를 추가하려면 어떻게 해야 하나요? C#에서 iTextSharp를 사용하여 페이지 번호를 추가하려면 PdfPageEventHelper에서 상속하는 사용자 지정 클래스를 만들면 됩니다. 페이지 번호를 삽입하려면 OnEndPage 메서드를 재정의하고 이 이벤트를 PdfWriter 인스턴스에 첨부합니다. PDF가 다양한 분야에서 중요한 이유는 무엇인가요? PDF는 텍스트와 이미지의 일관된 형식을 유지하므로 기업 전반의 문서 작성 및 송장 발행에 필수적입니다. 전문적인 방식으로 문서를 제시하는 데 신뢰할 수 있습니다. PDF 조작에 IronPDF를 사용하면 어떤 이점이 있나요? IronPDF는 .NET 환경 내에서 PDF를 만들고, 보고, 편집할 수 있는 강력한 기능을 제공합니다. HTML, JavaScript 및 이미지를 PDF로 변환하는 데 탁월하며 사용자 정의 머리글, 바닥글 및 워터마크를 지원합니다. IronPDF는 JavaScript를 지원하여 HTML을 PDF로 변환할 수 있나요? 예, IronPDF는 웹 브라우저에 표시되는 레이아웃과 기능을 그대로 유지하면서 JavaScript를 포함한 HTML 콘텐츠를 PDF로 변환할 수 있습니다. C# 프로젝트에 IronPDF를 설치하려면 어떻게 해야 하나요? IronPDF는 Visual Studio의 NuGet 패키지 관리자를 사용하여 설치할 수 있습니다. 'IronPDF'를 검색하여 프로젝트에 추가하기만 하면 기능을 사용할 수 있습니다. IronPDF에서 제공하는 평가판 기간의 의미는 무엇인가요? IronPDF의 평가판 기간을 통해 개발자는 워터마크가 표시된 평가판을 통해 실제 애플리케이션에서 기능을 살펴볼 수 있으므로 라이선스를 구매하기 전에 적합성을 평가할 수 있습니다. 페이지 번호를 추가하는 데 있어 iTextSharp와 IronPDF를 어떻게 비교하나요? ITextSharp는 페이지 번호를 추가하기 위해 이벤트 처리를 사용하는 반면, IronPDF는 머리글과 바닥글에 HTML 템플릿을 사용하여 보다 간단한 접근 방식을 제공하므로 사용 편의성을 원하는 .NET 개발자에게 이상적입니다. C# 프로젝트용 PDF 라이브러리를 선택할 때 고려해야 할 사항은 무엇인가요? 각 라이브러리가 제공하는 기능을 고려하세요. 예를 들어 IronPDF는 HTML을 PDF로 변환하는 데 특화되어 있으며 .NET 프레임워크와 잘 통합되는 반면, iTextSharp는 강력한 암호화 및 텍스트 추출 기능을 제공합니다. 페이지 번호 추가를 위해 iTextSharp가 .NET 10과 호환되나요, 아니면 iText 7을 사용해야 하나요? iTextSharp(버전 5.x)는 공식적으로 사용되지 않으며 유지 관리 모드에 있으며, 보안 수정 사항만 제공되며 새로운 기능 업데이트는 없습니다. 이 도구는 .NET 10을 직접 대상으로 하지 않으며 최신 .NET 릴리스에서 사용하면 호환성 제한이 발생할 수 있습니다. 새 프로젝트 또는 .NET 10으로 업그레이드하는 프로젝트의 경우 최신 프레임워크를 지원하고 iTextSharp보다 개선된 기능이 포함된 iText 7(또는 iText Core)을 강력히 권장합니다. ([itextpdf.com](https://itextpdf.com/products/itextsharp?utm_source=openai)) 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 게시됨 1월 20, 2026 Generate PDF Using iTextSharp in MVC vs IronPDF: A Complete Comparison ITextSharp와 IronPDF를 사용하여 ASP.NET MVC에서 PDF 생성 방법을 비교하세요. 어떤 라이브러리가 더 나은 HTML 렌더링과 더 쉬운 구현을 제공하는지 알아보세요. 더 읽어보기 업데이트됨 1월 7, 2026 Ghostscript GPL vs IronPDF: Technical Comparison Guide 고스트스크립트 GPL과 IronPDF의 주요 차이점을 알아보세요. AGPL 라이선스와 상용, 명령줄 스위치와 네이티브 .NET API, HTML-PDF 기능을 비교해 보세요. 더 읽어보기 업데이트됨 1월 21, 2026 Which ASP.NET PDF Library Offers the Best Value for .NET Core Development? ASP.NET Core 애플리케이션을 위한 최고의 PDF 라이브러리를 찾아보세요. IronPDF의 Chrome 엔진과 Aspose 및 Syncfusion의 대안을 비교해 보세요. 더 읽어보기 C# 리포팅 도구(기능 비교)How to Read PDF Documents in C# usi...
게시됨 1월 20, 2026 Generate PDF Using iTextSharp in MVC vs IronPDF: A Complete Comparison ITextSharp와 IronPDF를 사용하여 ASP.NET MVC에서 PDF 생성 방법을 비교하세요. 어떤 라이브러리가 더 나은 HTML 렌더링과 더 쉬운 구현을 제공하는지 알아보세요. 더 읽어보기
업데이트됨 1월 7, 2026 Ghostscript GPL vs IronPDF: Technical Comparison Guide 고스트스크립트 GPL과 IronPDF의 주요 차이점을 알아보세요. AGPL 라이선스와 상용, 명령줄 스위치와 네이티브 .NET API, HTML-PDF 기능을 비교해 보세요. 더 읽어보기
업데이트됨 1월 21, 2026 Which ASP.NET PDF Library Offers the Best Value for .NET Core Development? ASP.NET Core 애플리케이션을 위한 최고의 PDF 라이브러리를 찾아보세요. IronPDF의 Chrome 엔진과 Aspose 및 Syncfusion의 대안을 비교해 보세요. 더 읽어보기