<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tayyab Ali</title>
    <description>The latest articles on DEV Community by Tayyab Ali (@tayyabcodes).</description>
    <link>https://dev.to/tayyabcodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F807896%2F99f70c7e-dc0d-41ca-81e7-fd2b014d1d6d.jpg</url>
      <title>DEV Community: Tayyab Ali</title>
      <link>https://dev.to/tayyabcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tayyabcodes"/>
    <language>en</language>
    <item>
      <title>TypeScript PDF Libraries (Free &amp; Paid Tools Comparison) for Developers</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 14 Nov 2025 08:35:54 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/typescript-pdf-libraries-free-paid-tools-comparison-for-developers-1641</link>
      <guid>https://dev.to/tayyabcodes/typescript-pdf-libraries-free-paid-tools-comparison-for-developers-1641</guid>
      <description>&lt;p&gt;TypeScript has become the standard for building reliable JavaScript applications, and generating PDF files is a common requirement in modern web development. You might need to create invoices for e-commerce platforms, generate reports for analytics dashboards, or build document management systems with form-filling capabilities. However, working with PDFs in TypeScript comes with specific challenges. The PDF specification is complex, library options vary widely in features, and licensing costs can range from free to thousands of dollars annually. To address these challenges, developers have several solid options available. &lt;/p&gt;

&lt;p&gt;Some &lt;a href="https://www.npmjs.com/package/pdf-lib" rel="noopener noreferrer"&gt;TypeScript PDF libraries&lt;/a&gt; are entirely free, open-source, and offer native TypeScript support. Others offer commercial licenses with enterprise features, dedicated support, and advanced capabilities like real-time collaboration and digital signatures. Some libraries work only in browsers, while others support both Node.js and browser environments. You'll need to choose based on your budget, feature requirements, and deployment environment.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore four popular TypeScript PDF libraries, covering both free and paid options. Each has its strengths and limitations. By the end, you'll have a clear understanding of which library best fits your project needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. pdf-lib: TypeScript PDF Generation library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwwjv8mocmuru2k0jkeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwwjv8mocmuru2k0jkeg.png" alt=" " width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pdflib.com/" rel="noopener noreferrer"&gt;pdf-lib&lt;/a&gt; is a TypeScript-first PDF library designed for both creating and modifying PDF documents in any JavaScript environment. Written entirely in TypeScript and compiled to pure JavaScript, it stands out as one of the few open source libraries that handle both PDF creation and manipulation without relying on native dependencies. This library excels at tasks like form filling, PDF merging, document splitting, and adding text or images to existing PDFs. Its imperative API gives developers precise control over PDF operations, though this comes at the cost of manual layout calculations for complex documents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of pdf-lib
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Native TypeScript support with built-in type definitions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Universal JavaScript runtime compatibility across browsers, Node.js, Deno, and React Native&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Powerful PDF modification capabilities for editing existing documents from a blank page&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tree-shakable modules with a clean API and zero external dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strong form handling support for creating and filling various field types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports Uint8Array and ArrayBuffer for flexible font data management&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of pdf-lib
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Manual layout calculations required for complex documents&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited support for complex form features like conditional logic or live validation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No built-in rendering capabilities for viewing PDFs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No HTML or CSS support for content generation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some API methods feel outdated compared to modern JavaScript practices&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. jsPDF
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcz6yrj479c9v8ogmsyd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcz6yrj479c9v8ogmsyd.png" alt=" " width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://parall.ax/products/jspdf" rel="noopener noreferrer"&gt;jsPDF&lt;/a&gt; is a pioneering client-side JavaScript library for generating PDF documents entirely in the browser. First released around 2010, it became one of the earliest solutions for creating PDFs without server-side processing. jsPDF provides TypeScript support through built-in type definitions. It assists TypeScript developers who need quick, lightweight PDF generation.&lt;/p&gt;

&lt;p&gt;This library primarily works on the client side, though it also supports Node.js environments via dedicated build files. jsPDF excels at creating simple PDFs with text, images, shapes, and vector graphics. Its straightforward API allows developers to generate documents with minimal code. This library supports custom fonts through TTF files and offers various plugins for extended functionality, including table generation and HTML-to-PDF conversion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of jsPDF
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Built-in TypeScript type definitions with no separate @types package required&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lightweight and fast for simple PDF generation tasks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pure client-side operation eliminates server-side processing requirements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works in both browser and Node.js environments with automatic version detection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Large community with over 30,400 GitHub stars and extensive third-party plugins&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports custom TTF fonts for multi-language documents beyond the Latin alphabet&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MIT license allows unrestricted commercial use without restrictions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of jsPDF
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Struggles with complex layouts requiring manual positioning and calculations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited support for CSS or HTML styles without additional plugins like html2canvas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No built-in PDF rendering or viewing capabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cannot edit or manipulate existing PDF documents, only create new ones&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lacks advanced features like digital signatures, form manipulation, or PDF/A conversion&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTML-to-PDF conversion requires external dependencies and produces suboptimal results&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Standard fonts are restricted to the ASCII codepage, requiring custom font embedding for UTF-8&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resource-intensive for complex documents can impact browser performance and memory&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. pdfme: Generating PDFs in TypeScript
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ca09mydfrkz9issdljd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ca09mydfrkz9issdljd.png" alt=" " width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pdfme.com/" rel="noopener noreferrer"&gt;pdfme&lt;/a&gt; is an open-source PDF generation library built entirely in TypeScript with a React-based UI template editor. Created to simplify PDF design and generation, it takes a declarative, template-based approach that eliminates manual layout calculations.&lt;/p&gt;

&lt;p&gt;This library is completely free under the MIT license and works in both browser and Node.js environments. pdfme provides separate packages for generation, UI components, and schemas, with built-in support for text, images, barcodes, and custom plugins.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of pdfme
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Written entirely in TypeScript with full native type support&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WYSIWYG template designer with a drag-and-drop interface similar to Google Slides&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works in both browser and Node.js environments with no native dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built-in plugin system for images, barcodes, QR codes, and custom schemas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Active development with regular updates and community support&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of pdfme
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Steeper learning curve for developers unfamiliar with template-based approaches&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited functionality compared to full-featured PDF viewers with annotations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lacks advanced features like digital signatures or PDF/A conversion&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Template-centric workflow may not suit all use cases requiring low-level control&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires Node.js version 16 or higher&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less comprehensive than commercial solutions for enterprise requirements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Nutrient Web SDK: Handle Multiple PDFs Easily
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32i2s009u38oeqhp8slf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32i2s009u38oeqhp8slf.png" alt=" " width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.nutrient.io/sdk/web/" rel="noopener noreferrer"&gt;Nutrient Web SDK&lt;/a&gt; brings professional PDF capabilities to TypeScript applications. This commercial JavaScript library handles viewing, annotating, editing, and signing documents directly in the browser. It works with PDFs without requiring a server.&lt;/p&gt;

&lt;p&gt;The SDK integrates with any TypeScript project via npm. You get type definitions for TypeScript out of the box. Developers can deploy it in three ways: entirely client-side using WebAssembly, paired with Document Engine for server-side processing, or through the cloud-hosted DWS Viewer API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of Nutrient Web SDK
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Full TypeScript support with native type definitions included in the package&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works entirely client-side with no server required for basic operations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Includes 30+ features like annotations, digital signatures, form filling, and text editing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built on the PDFium rendering engine for reliable, high-fidelity document display&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Professional support with direct access to engineering teams&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Detailed documentation with code samples and integration guides&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Three deployment options (client-side, server-backed, or cloud-hosted)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can process documents offline once loaded in the browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customizable UI that can match your application's design&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of Nutrient Web SDK
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Commercial license required after trial period, with no free tier&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pricing is  not publicly disclosed and varies by project requirements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A complex pricing structure requires upfront analysis to avoid surprise costs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires strong technical knowledge to optimize distribution and performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;License keys are tied to specific domains listed in your subscription&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Heavy initial download for the WebAssembly core and assets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No monthly subscription option for short-term projects&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Choosing Your Library
&lt;/h2&gt;

&lt;p&gt;Your choice depends on your specific needs. Creating PDFs from scratch? Look at pdf-lib or jsPDF. Need a template-based approach with a visual editor? Consider pdfme. Want advanced features like annotations and digital signatures? Nutrient Web SDK delivers those capabilities.&lt;/p&gt;

&lt;p&gt;Budget plays a significant role. Open-source libraries cost nothing upfront but require more development time. You'll build features yourself and troubleshoot issues independently. Commercial solutions include support and pre-built features, but you'll pay licensing fees that can reach thousands annually.&lt;/p&gt;

&lt;p&gt;Look at each project's GitHub activity. Active repositories with recent commits and engaged contributors usually resolve bugs faster. Check the issue tracker to see how maintainers respond to problems.&lt;/p&gt;

&lt;p&gt;Test thoroughly before deploying. PDF generation errors frustrate users and create support tickets. Validate file inputs, handle edge cases, and test across different browsers. Run stress tests with various document sizes and complexity levels. Your testing effort now prevents user complaints later.&lt;/p&gt;

</description>
      <category>pdflibraries</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>React PDF Libraries: Free &amp; Paid Tools Comparison (Developer Guide)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Mon, 10 Nov 2025 06:51:22 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/react-pdf-libraries-free-paid-tools-comparison-developer-guide-hcp</link>
      <guid>https://dev.to/tayyabcodes/react-pdf-libraries-free-paid-tools-comparison-developer-guide-hcp</guid>
      <description>&lt;p&gt;React is a popular JavaScript library for building amazing web apps, and working with PDFs in React has numerous use cases. For example, you may need to create a web app that offers invoice generation, report creation, or contract viewing and signing. However, PDF manipulation in React presents unique challenges. To address these challenges, the React community has built some solid solutions. Some &lt;a href="https://www.npmjs.com/package/@react-pdf/renderer" rel="noopener noreferrer"&gt;React PDF libraries&lt;/a&gt; focus solely on creating PDFs from scratch, while others concentrate on enhancing the viewing experience of existing PDFs. Some libraries work natively with React components, and some don't. You'll need to choose depending on your requirements. You may need to use more than one library to achieve your goal.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore four popular React PDF libraries, both open-source and paid options. Each has its pros and cons. By the end, you'll have a clear understanding of which library best fits your project needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. react-pdf
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbyy6251xjgnz2qwz6fh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbyy6251xjgnz2qwz6fh.png" alt=" " width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://react-pdf.org/" rel="noopener noreferrer"&gt;@react-pdf/renderer&lt;/a&gt; is a popular open-source React PDF library. It is designed to work with PDFs both in the browser and on the server. Its source code is available on GitHub, with over 15,000 stars. It has over 860,000 weekly downloads.&lt;/p&gt;

&lt;p&gt;This library uses React components with specialized primitives, including Page, View, Text, and Stylesheet, to build PDF document components. It supports adding headers, footers, page breaks, and dynamic text. Developers don't need to learn an entirely new framework and can leverage their existing React knowledge to work with this library.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of @react-pdf/renderer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It can generate PDFs directly in the browser and on the server, enabling seamless integration into automated workflows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It offers a rich set of features, including support for headers, footers, page numbers, SVG graphics, and dynamic text rendering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This library gets regular updates from its contributors. Developers can benefit from its large community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It handles page breaks very well, which is a major benefit for developers working with PDFs in React.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The main advantage of this library is that users don't need to learn new APIs or follow a steep learning curve, as it relies on native React components.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of @react-pdf/renderer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This library has limited support for CSS, which is a significant drawback for styling PDFs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It does not support DOM components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It only supports React versions 16 and 17, with no support for the latest versions of React.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This library does not support creating fillable PDF forms.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. jsPDF: Client-side JavaScript Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrazqqjgfzo7cbjz5o32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrazqqjgfzo7cbjz5o32.png" alt=" " width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://parall.ax/products/jspdf" rel="noopener noreferrer"&gt;jsPDF&lt;/a&gt; is a popular client-side JavaScript library. This library is one of the top downloaded libraries in the JavaScript ecosystem. It has more than &lt;a href="https://github.com/parallax/jsPDF" rel="noopener noreferrer"&gt;30,000 stars on GitHub&lt;/a&gt; and receives weekly downloads of over 260,000. It is not specific to React, but you can use this library by importing it into React projects. &lt;/p&gt;

&lt;p&gt;This library supports the creation of PDF files, allowing the addition of text, images, and shapes. Also, developers can add multiple pages with break actions, password protection, and annotations to the PDF file. And it supports all its features in the browser; no server is required to perform any action. It provides an HTML() function to convert HTML to PDF files directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of jsPDF:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Works entirely in the browser, no server needed &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Small package size keeps your app lightweight &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The straightforward API makes it easy for developers to create basic PDFs without extensive configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can save files directly to user devices &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports adding image file types and external links &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has compatibility across all modern browsers &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Its long-standing presence in the ecosystem means the codebase is mature, stable, and well-tested.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It integrates smoothly with existing projects, requiring minimal architectural changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of jsPDF:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This library is not designed with React patterns in mind, which may lead to less intuitive integration in React applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating complex layouts requires manual positioning calculations, which can be both time-consuming and prone to errors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It offers limited built-in styling capabilities compared to more modern component-based PDF libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This library lacks the ability to read, parse, or modify existing PDF files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generating sophisticated documents with advanced features requires writing significantly more boilerplate code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No native React component integration &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implementing complex forms with custom styling demands considerable manual effort and custom development.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Syncfusion React PDF Viewer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffm44f1wq6q8h3mh1wjzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffm44f1wq6q8h3mh1wjzd.png" alt=" " width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.syncfusion.com/pdf-viewer-sdk/react-pdf-viewer" rel="noopener noreferrer"&gt;Syncfusion React PDF Viewer&lt;/a&gt; is a commercial component that lets you view and print PDF files within web applications. You get standard features like zooming, scrolling, text search, and copy functions. The component works well for business applications that need document management tools.&lt;/p&gt;

&lt;p&gt;You can view PDFs, add annotations, fill out forms, and print documents directly in your browser. The rendering engine loads pages only when needed, which keeps memory usage low. Navigation works through thumbnails, bookmarks, hyperlinks, and a table of contents. You can review documents using highlights, sticky notes, stamps, drawings, shapes, and ink annotations. It also handles interactive forms, digital signatures, and redaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of Syncfusion React PDF Viewer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;AI tools extract text, analyze content, and power intelligent search&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pages load progressively for smooth performance with large files&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add highlights, notes, stamps, drawings, and shapes to PDFs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Full support for interactive forms with real-time editing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All operations run locally with no external data transfers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fully compatible with React DOM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Meets WCAG accessibility standards with keyboard navigation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports custom toolbars and localization for global use&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of Syncfusion React PDF Viewer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Requires a paid license except for companies under $1M revenue&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pricing increases significantly as your team grows&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Comes bundled with 140+ components you may not need&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Documentation is confusing and complex to navigate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cannot purchase the PDF viewer separately from the full suite&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some deployments need specific server configurations&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Nutrient React PDF Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpzgudhstmursbqt7g49y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpzgudhstmursbqt7g49y.png" alt=" " width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.nutrient.io/guides/web/react/" rel="noopener noreferrer"&gt;Nutrient Web SDK&lt;/a&gt; is a JavaScript library that integrates with React. You can incorporate it into new or existing projects to handle PDFs in the browser. Users can view, annotate, and edit PDF files without leaving your application.&lt;/p&gt;

&lt;p&gt;The library features over 30 options, complete with a user-friendly interface. You can load, save, convert, and edit 15 different file types, including PDFs, Office documents, and images. Major companies, including Autodesk, Disney, UBS, Dropbox, IBM, and Lufthansa, utilize Nutrient for their document management needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of Nutrient React PDF Library:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Includes PDF viewing, annotations, editing, signing, forms, and redaction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports 15 different file formats without needing multiple libraries&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Renders large files smoothly without performance issues&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ready-to-use UI saves months of custom development time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Comes with commercial support, regular updates, and technical help &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works on Chrome, Firefox, Safari, Edge, and Firefox ESR&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons of Nutrient React PDF Library:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Expensive licensing costs that many companies cannot afford&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complex pricing with separately charged modules per document&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Setup can be complex with inadequate early-stage documentation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires wire transfers for payment instead of standard methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited customization compared to building your own solution&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performance slows down with files larger than 50 MB&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The trial version adds watermarks that interfere with testing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Choosing Your Library
&lt;/h2&gt;

&lt;p&gt;Your choice depends on what you need to do with PDFs. Creating PDF files from data? Try &lt;strong&gt;react-pdf&lt;/strong&gt; or &lt;strong&gt;jsPDF&lt;/strong&gt;. Do you need to display existing PDFs with rich features? Look at Syncfusion or Nutrient. Budget matters too. Open-source options cost nothing but may require more development time. Commercial libraries include support and save development hours, but require payment.&lt;/p&gt;

&lt;p&gt;Consider your existing projects and how each library aligns with them. Some work better with specific architectures. Review the documentation and example code before committing. Most libraries allow you to test before purchasing.&lt;/p&gt;

&lt;p&gt;All our sponsors and contributors help maintain these libraries. Check each project's GitHub page to see activity levels and community support. Active projects with many contributors tend to have fewer unresolved issues. Remember to test thoroughly. An error that occurred during PDF generation or viewing can frustrate users. Handle edge cases, validate file inputs, and test across browsers.&lt;/p&gt;

</description>
      <category>development</category>
      <category>reactjsdevelopment</category>
      <category>pdflibrary</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Read Excel Files Line by Line in VB .NET (Example)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 25 Jul 2025 08:05:08 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/how-to-read-excel-files-line-by-line-in-vb-net-example-55l2</link>
      <guid>https://dev.to/tayyabcodes/how-to-read-excel-files-line-by-line-in-vb-net-example-55l2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8n1iltzbb3ggl9orckd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8n1iltzbb3ggl9orckd.png" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Microsoft_Excel" rel="noopener noreferrer"&gt;Processing Excel data&lt;/a&gt; is a common challenge in business and scientific applications, often involving complex data extraction for reports, database integration, or log parsing. Traditional methods using Microsoft Office Interop are problematic due to their dependency on an installed Excel application, high resource consumption, and compatibility issues across versions. These drawbacks are particularly significant for server-side or cloud deployments where Excel installation is impractical.&lt;/p&gt;

&lt;p&gt;This tutorial introduces &lt;a href="https://ironsoftware.com/csharp/excel/" rel="noopener noreferrer"&gt;IronXL&lt;/a&gt;, a robust .NET library that overcomes these limitations by eliminating the need for Excel to be installed. We will provide a technical, step-by-step guide on how to use IronXL to efficiently read Excel files line by line within a VB.NET application, offering a powerful and independent solution for developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Read an Excel File Line by Line in &lt;a href="http://VB.NET" rel="noopener noreferrer"&gt;VB.NET&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;1. Create the VB.NET Console project in Visual Studio&lt;/p&gt;

&lt;p&gt;2. Install the Excel library using the NuGet Package Manager&lt;/p&gt;

&lt;p&gt;3. Load the Excel file in the program using the Workbook.Load method&lt;/p&gt;

&lt;p&gt;4. Read Excel file using Excel library function in the for loop&lt;/p&gt;

&lt;p&gt;6. Print Excel file data on a Console&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we dive into the code, ensure you have the necessary development environment set up. This will ensure a smooth and efficient coding experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Visual Studio Installation
&lt;/h3&gt;

&lt;p&gt;You'll need &lt;strong&gt;Visual Studio 2017 or a more recent version&lt;/strong&gt; installed on your development machine. These versions offer excellent support for .NET development, including advanced debugging tools and integrated NuGet package management, which are crucial for working with external libraries like IronXL.&lt;/p&gt;

&lt;h3&gt;
  
  
  IronXL Library Installation
&lt;/h3&gt;

&lt;p&gt;IronXL is distributed as a NuGet package, making its installation straightforward. You have two primary methods to add it to your project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using the NuGet Package Manager Console:&lt;/strong&gt; Within Visual Studio, navigate to Tools &amp;gt; NuGet Package Manager &amp;gt; Package Manager Console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4w55wmvs3yrswf8ib2x7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4w55wmvs3yrswf8ib2x7.png" alt=" " width="633" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the console window, execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Install-Package IronXL.Excel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl973sov729uw0e3fye6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl973sov729uw0e3fye6b.png" alt=" " width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command will download the IronXL package and its dependencies, automatically adding the necessary references to your &lt;a href="http://VB.NET" rel="noopener noreferrer"&gt;VB.NET&lt;/a&gt; project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using the NuGet Package Manager GUI:&lt;/strong&gt; Alternatively, you can use the graphical interface. Right-click on your project in the Solution Explorer and select Manage NuGet Packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg115ck72qga8sdq91l67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg115ck72qga8sdq91l67.png" alt=" " width="624" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the "Browse" tab of the NuGet Package Manager window, search for IronXL. Locate the package published by "Iron Software" and click the Install button. Follow any prompts to complete the installation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1ahfqxeguhhotyfonwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1ahfqxeguhhotyfonwd.png" alt=" " width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once IronXL is successfully installed, you can use it in your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Read an Excel file Line by Line VB.NET
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Prepare the Excel File
&lt;/h3&gt;

&lt;p&gt;Let’s assume we have a file called employees.xlsx with the following structure:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Department&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;John Doe&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Jane Smith&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Sam Brown&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys78hkrk8jlih2a43352.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys78hkrk8jlih2a43352.png" alt=" " width="430" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please save it to your project directory or provide the full path when loading it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Creating Your VB.NET Project
&lt;/h3&gt;

&lt;p&gt;To begin, you'll need a new Visual Basic .NET project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open Visual Studio&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select &lt;strong&gt;"Create a new project"&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppxaum9yti339xu5sj8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppxaum9yti339xu5sj8w.png" alt=" " width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose the &lt;strong&gt;"Console App (VB.NET)"&lt;/strong&gt; template. This type of project is perfect for demonstrating file operations without the complexities of a GUI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcycehqpcwpns80fz1d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcycehqpcwpns80fz1d6.png" alt=" " width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Give your project a descriptive name, something like &lt;strong&gt;"ExcelReaderVB"&lt;/strong&gt;, and click "Create".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24f80gyv4t078x5hiefn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24f80gyv4t078x5hiefn.png" alt=" " width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This sets up the basic structure for your application, including a Program.vb file where you'll write your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Importing the IronXL Namespace
&lt;/h3&gt;

&lt;p&gt;To access IronXL's functionalities, you need to import its namespace into your code file. At the very top of your Module1.vb file (or any other code file where you'll be using IronXL), add the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Imports IronXL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This statement makes all the classes, methods, and properties within the IronXL namespace directly accessible in your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Loading the Excel File
&lt;/h3&gt;

&lt;p&gt;Now that IronXL is imported, the first step in processing an Excel document of xlsx format is to &lt;a href="https://ironsoftware.com/csharp/excel/how-to/load-spreadsheet/" rel="noopener noreferrer"&gt;load the spreadsheet&lt;/a&gt; into the code. You can use the .xls file in the same way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dim workbook As WorkBook = WorkBook.Load("employees.xlsx")
Dim sheet As WorkSheet = workbook.DefaultWorkSheet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Working with Excel files is straightforward with IronXL! The line &lt;strong&gt;Dim workbook As WorkBook = WorkBook.Load("employees.xlsx")&lt;/strong&gt; tells IronXL to open and read your Excel workbook, loading all worksheet data into a WorkBook object.&lt;/p&gt;

&lt;p&gt;Once loaded, you can access your data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Default Sheet:&lt;/strong&gt; &lt;strong&gt;Dim sheet As WorkSheet = workbook.DefaultWorkSheet&lt;/strong&gt; gets you the first Excel worksheet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Specific Sheet:&lt;/strong&gt; Need a different one? Use &lt;strong&gt;workbook.GetWorkSheet("SheetName")&lt;/strong&gt; by name, or by its index.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reading the File Row by Row
&lt;/h3&gt;

&lt;p&gt;This is the core of our task: iterating through each row of Excel data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;' Loop through each row using WorkSheet.Rows, which returns IEnumerable(Of Range)
For Each row As Range In sheet.Rows
    Dim id As String = row(0).Text
    Dim name As String = row(1).Text
    Dim department As String = row(2).Text

    Console.WriteLine($"ID: {id}, Name: {name}, Department: {department}")
Next

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the technical breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For Each row As Range In sheet.Rows&lt;/strong&gt;: The sheet.Rows property returns an enumerable collection of Range objects. This allows you to use a For Each loop to iterate through every row in the worksheet sequentially. Each row in this loop is a Range object representing a full row.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dim id As String = row(0).Text&lt;/strong&gt;: Each Range object representing a row can be indexed like an array to access individual cells within that row. row(0) refers to the cell in the first column (column A) of the current row. We then access its Text property to get the cell value displayed as a string. It follows the zero-based index.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Console.WriteLine(...)&lt;/strong&gt;: This line simply prints the extracted data to the console, demonstrating that the data has been successfully read. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This loop will produce the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4z2x6cd5hwchzcf64kn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4z2x6cd5hwchzcf64kn.png" alt=" " width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Skipping Header Rows
&lt;/h3&gt;

&lt;p&gt;It's very common for the first row of an Excel sheet to contain headers rather than data. You'll want to skip this row during processing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dim isFirstRow As Boolean = True

For Each row As Range In sheet.Rows
    If isFirstRow Then
        isFirstRow = False
        Continue For ' Skip header row
    End If

    ' Reading columns using index-based access
    Dim id As String = row(0).Text
    Dim name As String = row(1).Text
    Dim department As String = row(2).Text

    Console.WriteLine($"ID: {id}, Name: {name}, Department: {department}")
Next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By introducing a &lt;strong&gt;Boolean flag isFirstRow&lt;/strong&gt;, we can conditionally skip the processing of the first iteration of the loop. Once the first row is encountered, the flag is set to False, and Continue For immediately moves the loop to the next row.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling Empty Rows (Optional)
&lt;/h3&gt;

&lt;p&gt;Excel files can sometimes contain empty rows, especially at the bottom of a dataset, which you might want to ignore to prevent errors or process only meaningful data.&lt;/p&gt;

&lt;p&gt;You can add a check within your loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If String.IsNullOrWhiteSpace(row.Columns(0).ToString()) Then
    Continue For ' Skip this row if the first column is empty or whitespace
End If

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;strong&gt;if statement&lt;/strong&gt; checks if the content of the first column (row. Column (0)) is null, empty, or consists only of whitespace characters. If it is, Continue For is executed, moving to the next row without processing the current one. &lt;/p&gt;

&lt;h3&gt;
  
  
  Encapsulating Logic into a Function
&lt;/h3&gt;

&lt;p&gt;For better code organization, reusability, and readability, it's good practice to encapsulate your Excel reading logic within a dedicated function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Imports IronXL

Private Sub ReadExcelFile(filePath As String)
    Try
        Dim workbook As WorkBook = WorkBook.Load(filePath)
        Dim sheet As WorkSheet = workbook.DefaultWorkSheet
        Dim isFirstRow As Boolean = True

        For Each row As Range In sheet.Rows
            If isFirstRow Then
                isFirstRow = False
                Continue For ' Skip header row
            End If

            ' Optional: Skip empty rows based on the first column
            If String.IsNullOrWhiteSpace(row(0).Text) Then
                Continue For
            End If

            Dim id As String = row(0).Text
            Dim name As String = row(1).Text
            Dim department As String = row(2).Text

            Console.WriteLine($"ID: {id}, Name: {name}, Department: {department}")
        Next
    Catch ex As Exception
        Console.WriteLine("Error reading Excel file: " &amp;amp; ex.Message)
    End Try
End Sub


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To execute this function from your Main subroutine (the entry point of your console application), call it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sub Main()
    ReadExcelFile("employees.xlsx")
    Console.WriteLine("Press any key to exit.")
    Console.ReadKey() ' Keep console open until a key is pressed
End Sub

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure makes your code modular and easier to maintain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error Handling
&lt;/h3&gt;

&lt;p&gt;You can wrap your entire file reading logic within a Try...Catch block, as demonstrated in the ReadExcelFile function above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Try
    ReadExcelFile("employees.xlsx")
Catch ex As Exception
    Console.WriteLine("Error reading Excel file: " &amp;amp; ex.Message)
End Try

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that if an error occurs during file loading or processing, your application won't crash. Instead, it will catch the Exception and print an informative error message to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjb08vmupft41wu5ii47h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjb08vmupft41wu5ii47h.png" alt=" " width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reading Excel files line by line in &lt;a href="http://VB.NET" rel="noopener noreferrer"&gt;VB.NET&lt;/a&gt; is simple with IronXL, giving you precise control for applications like employee trackers or product catalogs. While IronXL handles many low-level complexities, it's still important to write solid logic for edge cases such as empty cells or malformed files. You can explore IronXL's capabilities with a &lt;a href="https://ironsoftware.com/csharp/excel/licensing/" rel="noopener noreferrer"&gt;free trial&lt;/a&gt;, and commercial licenses are available starting from $749.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Comparative Analysis of C# PDF Libraries for.NET Developers</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 16 May 2025 09:58:07 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/a-comparative-analysis-of-c-pdf-libraries-fornet-developers-4bd</link>
      <guid>https://dev.to/tayyabcodes/a-comparative-analysis-of-c-pdf-libraries-fornet-developers-4bd</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;I. Executive Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Purpose of the Report:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;This report provides an in-depth comparative analysis of six leading C# PDF libraries, encompassing three commercial options (&lt;a href="https://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt;, iText 7, Aspose.PDF for .NET) and three open-source alternatives (PuppeteerSharp, PDFsharp, QuestPDF). The evaluation is tailored for .NET developers, technical leads, and solution architects, aiming to furnish them with practical insights and extensive C# code examples. This information is intended to facilitate an informed selection of the most suitable library for diverse project requirements in the 2024-2025 timeframe, ensuring that development teams can choose the best tool for their specific needs.&lt;/p&gt;

&lt;p&gt;The landscape of C# PDF libraries presents a variety of solutions, each with distinct strengths that cater to different development scenarios. Commercial libraries generally offer comprehensive feature sets, dedicated support channels, and simplified licensing for enterprise use, making them a robust choice for large-scale applications. In contrast, open-source libraries provide cost-effectiveness, flexibility, and often, strong community backing, which can be highly beneficial for projects with limited budgets or those requiring custom modifications. Understanding these fundamental differences is the first step in navigating the selection process.&lt;/p&gt;

&lt;p&gt;For high-fidelity HTML-to-PDF conversion, libraries leveraging browser engines, such as IronPDF and PuppeteerSharp, demonstrate notable capabilities, accurately rendering complex web pages. For comprehensive, enterprise-grade PDF manipulation, including intricate document construction and robust security features, iText 7 and &lt;a href="https://ironpdf.com/competitors/aspose-vs-ironpdf/" rel="noopener noreferrer"&gt;Aspose.PDF&lt;/a&gt; for .NET are prominent contenders, offering a wide array of tools for advanced PDF tasks. &lt;a href="https://ironpdf.com/blog/compare-to-other-components/pdfsharp-read-pdf/" rel="noopener noreferrer"&gt;PDFsharp&lt;/a&gt; is well-regarded for its lightweight nature and programmatic PDF creation with minimal overhead, suitable for simpler, performance-sensitive applications. &lt;a href="https://ironpdf.com/blog/compare-to-other-components/questpdf-html-to-pdf-alternatives/" rel="noopener noreferrer"&gt;QuestPDF&lt;/a&gt; introduces a modern, fluent API approach for code-first document generation, appealing to developers who prefer a more contemporary coding style.&lt;/p&gt;

&lt;p&gt;The selection of a PDF library is increasingly influenced by the primary nature of the document content, leading to a significant trend in the divergence of library architecture. Some libraries, like IronPDF and Puppeteer Sharp, utilize embedded browser engines (typically Chromium-based) to achieve high fidelity in rendering HTML, CSS, and JavaScript to PDF. This approach is particularly beneficial when the source material is web-based and visual accuracy is paramount. These tools excel at transforming dynamic web content into static PDF documents while preserving the original layout and styling.&lt;/p&gt;

&lt;p&gt;Conversely, traditional libraries such as iText 7 and Aspose.PDF for .NET provide deep, programmatic control over the PDF object model, allowing for granular construction and manipulation of PDF elements directly in code. This gives developers fine-grained authority over every aspect of the PDF creation process, from text placement to complex graphical elements. QuestPDF offers a distinct, code-centric fluent API for document definition, providing a more declarative and readable way to construct documents programmatically. This distinction implies that development teams must carefully consider whether their primary input is HTML requiring accurate visual replication, or if they need to build PDFs element by element, dictating a fundamental choice in library architecture.&lt;/p&gt;

&lt;p&gt;Furthermore, licensing models play a critical role in the adoption and suitability of these libraries, often influencing decisions as much as technical capabilities. Open-source licenses vary significantly, with the AGPL license of iText 7's core presenting a different set of considerations (due to its "copyleft" nature, requiring derivative works to also be open-sourced under similar terms) compared to the more permissive MIT license offered by PDFsharp and QuestPDF (for its community tier), which allows for greater freedom in proprietary projects. Commercial libraries like IronPDF and Aspose.PDF for .NET provide straightforward commercial licenses, often tiered by features or developer seats, offering clear terms for business use. Consequently, budgetary constraints and an organization's stance on open-source licensing obligations are as pivotal as technical features in the library selection process.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;II. Introduction to C# PDF Libraries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Indispensable Role of PDFs in.NET Applications:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The Portable Document Format (PDF) has established itself as a cornerstone in digital document exchange, crucial for reporting, archiving, invoicing, and form processing within enterprise and web applications. For .NET developers, the ability to programmatically create, manipulate, and manage PDF documents is not merely a convenience but often a core requirement for delivering robust and professional software solutions. The demand for dynamic PDF generation from various data sources, conversion from web content, and secure document handling underscores the need for powerful and flexible C# PDF libraries. This necessity drives the continuous evolution and adoption of various tools within the .NET ecosystem.&lt;/p&gt;

&lt;p&gt;This report focuses on six specific C# PDF libraries: IronPDF, iText 7, &lt;a href="https://ironpdf.com/competitors/aspose-vs-ironpdf/" rel="noopener noreferrer"&gt;Aspose.PDF&lt;/a&gt; for .NET (commercial), and Puppeteer Sharp, &lt;a href="https://ironpdf.com/blog/compare-to-other-components/pdfsharp-read-pdf/" rel="noopener noreferrer"&gt;PDFsharp&lt;/a&gt;, &lt;a href="https://ironpdf.com/blog/compare-to-other-components/questpdf-html-to-pdf-alternatives/" rel="noopener noreferrer"&gt;QuestPDF&lt;/a&gt; (open-source). These libraries have been selected based on their significant market presence, the breadth and depth of features demonstrated in available technical documentation and community discussions, and to offer a balanced perspective on both commercial and open-source offerings. While numerous other libraries exist, such as Syncfusion PDF and &lt;a href="https://ironpdf.com/competitors/aspose-vs-ironpdf/" rel="noopener noreferrer"&gt;DinkToPdf&lt;/a&gt;, the chosen six provide a representative cross-section of the capabilities available to .NET developers. This selection aims to furnish developers with sufficient comparative material and code examples to facilitate a meaningful analysis for their specific project needs.&lt;/p&gt;

&lt;p&gt;The evolution of PDF libraries mirrors a broader trend in software development: the increasing prominence of web technologies—HTML, CSS, and JavaScript—as primary mediums for content generation, even for formats traditionally considered static, like PDF. Early PDF libraries were predominantly focused on programmatic object creation, allowing developers to draw lines, place text, and construct tables element by element with precise control. However, with the proliferation of web applications, a significant need arose to convert dynamic web content, such as reports and invoices generated as HTML, into PDF format seamlessly.&lt;/p&gt;

&lt;p&gt;This has led to the rise of libraries like PuppeteerSharp, Playwright, and IronPDF, which explicitly employ browser rendering engines (e.g., Chromium, WebKit) to ensure that the PDF output closely mirrors the appearance of content in a web browser. This paradigm shift signifies that for many modern use-cases, PDF generation has transitioned from a purely "drawn" format to a "rendered" one. This change enables developers with existing web skills to more easily produce complex and visually rich PDF documents without needing to learn intricate PDF-specific drawing commands, thereby streamlining the development process.&lt;/p&gt;

&lt;p&gt;Concurrently, the "free" attribute of open-source libraries often warrants careful consideration of associated complexities or potential hidden costs that might not be immediately apparent. For instance, PDFsharp, while permissively MIT-licensed and free to use, typically requires pairing with an additional library like HtmlRenderer for HTML-to-PDF conversion, adding another dependency to manage. iText 7's open-source core is available under the AGPL, a license that can impose obligations to share derivative source code, often leading commercial entities to opt for its paid commercial license to avoid these stipulations.&lt;/p&gt;

&lt;p&gt;DinkToPdf, another open-source option which acts as a wrapper for the wkhtmltopdf utility, introduces dependencies on native wkhtmltopdf libraries which must be managed for each target platform, potentially complicating deployment. In contrast, commercial libraries, despite their upfront licensing fees, frequently offer integrated solutions, bundled dependencies, and dedicated technical support. These benefits can potentially reduce the overall development and maintenance effort for complex projects. Thus, a comprehensive evaluation of a PDF library extends beyond its technical merits to include the total cost of ownership, encompassing development time, dependency management, and the availability and quality of support.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;III. In-Depth Library Profiles &amp;amp; Feature Analysis (with C# Code Examples)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This section provides a detailed profile of each selected library, covering its overview, licensing, key features, and C# code examples for common PDF operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;A. IronPDF (Commercial)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6aisv3sapbueem3ymvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6aisv3sapbueem3ymvs.png" alt="Image description" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overview and Licensing Model:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;IronPDF is marketed as a comprehensive C# PDF library for.NET developers, enabling the generation, conversion, and editing of PDF documents through what many find to be a &lt;a href="https://ironpdf.com/features/" rel="noopener noreferrer"&gt;user-friendly API&lt;/a&gt;. It's also listed on the &lt;a href="https://marketplace.visualstudio.com/items?itemName=Iron-Software.IronPdf" rel="noopener noreferrer"&gt;Visual Studio Marketplace&lt;/a&gt;. The library boasts over 100 features and notably leverages a Chrome rendering engine, which aims for high-fidelity, pixel-perfect HTML to PDF conversions.&lt;/p&gt;

&lt;p&gt;IronPDF's licensing is structured around &lt;a href="https://ironpdf.com/licensing/" rel="noopener noreferrer"&gt;perpetual licenses&lt;/a&gt;, available in various tiers (Lite, Plus, Professional, Unlimited). These are typically one-time purchases that include an initial year of support and updates. For ongoing support and newer versions, annual subscriptions or multi-year packages are available. To help with evaluation, IronPDF offers a fully functional &lt;a href="https://ironpdf.com/demos/" rel="noopener noreferrer"&gt;30-day free trial&lt;/a&gt;. The company emphasizes an "honest pricing" model, with clear tier definitions. Support channels include 24/5 live chat and direct access to engineering support, which can be initiated by &lt;a href="https://ironsoftware.com/contact-us/sales/" rel="noopener noreferrer"&gt;contacting sales&lt;/a&gt;. Further details on &lt;a href="https://ironpdf.com/licensing/extensions/" rel="noopener noreferrer"&gt;licensing extensions&lt;/a&gt; and the process of &lt;a href="https://ironpdf.com/how-to/license-keys/" rel="noopener noreferrer"&gt;applying software license keys&lt;/a&gt; can be found on their website.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A core strength of IronPDF lies in its &lt;a href="https://ironpdf.com/features/convert/" rel="noopener noreferrer"&gt;HTML to PDF rendering capabilities&lt;/a&gt;, which are powered by an embedded Chrome engine.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML String (Basic):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// PM &amp;gt; Install-Package IronPdf  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;h1&amp;gt;Hello IronPDF from HTML String\!&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_HtmlStringToPdf.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code snippet demonstrates the most stra ightforward form of HTML to PDF conversion; you can find a more &lt;a href="https://ironpdf.com/examples/using-html-to-create-a-pdf/" rel="noopener noreferrer"&gt;detailed code example&lt;/a&gt; on their site. The &lt;code&gt;ChromePdfRenderer&lt;/code&gt; is key to achieving &lt;a href="https://ironpdf.com/how-to/html-string-to-pdf/" rel="noopener noreferrer"&gt;accurate rendering of HTML structures from strings&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML String with Base URL (for local assets like CSS, images, JS):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="c1"&gt;// Assuming 'styles.css' and 'logo.png' are in 'C:\\project\\assets\\'  &lt;/span&gt;
&lt;span class="c1"&gt;// and HTML is: "&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;link rel='stylesheet' href='styles.css'&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='logo.png'&amp;gt; My Content&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;"  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;htmlWithAssets&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;link rel='stylesheet' href='styles.css'&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='logo.png'&amp;gt; Local Assets&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlWithAssets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;@"C:\\project\\assets\\"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_HtmlStringWithAssets.pdf"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The optional &lt;code&gt;BasePath&lt;/code&gt; parameter in &lt;code&gt;RenderHtmlAsPdf&lt;/code&gt; is crucial for resolving relative URLs within the HTML string to local file system paths. This allows for the seamless inclusion of local assets such as CSS, images, and JavaScript files.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From URL:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderUrlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://ironpdf.com"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_UrlToPdf.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method directly converts a live web page to a PDF. IronPDF's engine processes JavaScript, CSS, images, and forms present on the target URL. For a practical demonstration, refer to their &lt;a href="https://ironpdf.com/examples/converting-a-url-to-a-pdf/" rel="noopener noreferrer"&gt;URL to PDF conversion example&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML File:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="c1"&gt;// Assuming 'report_template.html' exists in the application's working directory  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlFileAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"report_template.html"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_HtmlFileToPdf.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach is ideal for converting pre-designed HTML templates that are stored as files. More information on this can be found in their &lt;a href="https://ironpdf.com/examples/file-to-pdf/" rel="noopener noreferrer"&gt;HTML file to PDF example&lt;/a&gt; and their guide on &lt;a href="https://ironpdf.com/how-to/html-file-to-pdf/" rel="noopener noreferrer"&gt;how to render HTML files to PDF&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From ASP.NET (ASPX WebForms):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add to Page_Load event in your ASPX page's code-behind (e.g., MyPage.aspx.cs)  &lt;/span&gt;
&lt;span class="c1"&gt;// using IronPdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// protected void Page_Load(object sender, EventArgs e)  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// AspxToPdf.RenderThis PageAsPdf (AspxToPdf.FileBehavior.Attachment, "MyAspNetPage.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;AspxToPdf.RenderThisPageAsPdf&lt;/code&gt; method offers a streamlined way to &lt;a href="https://ironpdf.com/technology/convert-aspx-to-pdf/" rel="noopener noreferrer"&gt;convert an ASPX page to PDF&lt;/a&gt;. The &lt;code&gt;FileBehavior.Attachment&lt;/code&gt; option prompts a download, while &lt;code&gt;FileBehavior.InBrowser&lt;/code&gt; attempts an inline display.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From Razor Views/Pages (CSHTML):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;&lt;strong&gt;ASP.NET Core MVC:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// In an MVC Controller action  &lt;/span&gt;
&lt;span class="c1"&gt;// Requires NuGet package: IronPdf.Extensions.Mvc.Framework  &lt;/span&gt;
&lt;span class="c1"&gt;// using IronPdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// public lActionResult ExportToPdf (MyViewModel model)  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// var renderer = new ChromePdfRenderer();  &lt;/span&gt;
&lt;span class="c1"&gt;// // 'MyRazorView.cshtml' is the view, 'model' is the data passed to it  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocument pdf = renderer.RenderView(this.ControllerContext, "\~/Views/Shared/MyRazorView.cshtml", model);  &lt;/span&gt;
&lt;span class="c1"&gt;// return File(pdf.BinaryData, "application/pdf", "MvcView.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// } &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IronPDF provides examples for &lt;a href="https://ironpdf.com/examples/cshtml-to-pdf-mvc-framework/" rel="noopener noreferrer"&gt;converting CSHTML to PDF within an MVC Framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ASP.NET Core Razor Pages:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In a Razor PageModel OnPostAsync method  &lt;/span&gt;
&lt;span class="c1"&gt;// Requires NuGet package: IronPdf.Extensions.Razor  &lt;/span&gt;
&lt;span class="c1"&gt;// using IronPdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// using IronPdf.Razor.Pages;  &lt;/span&gt;
&lt;span class="c1"&gt;// public class MyPageModel: PageModel  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// public List&amp;lt;Person&amp;gt; Persons { get; set; }  &lt;/span&gt;
&lt;span class="c1"&gt;// public lActionResult OnPostExportToPdf()  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// // Populate Persons data...  &lt;/span&gt;
&lt;span class="c1"&gt;// ViewData\["personList"\] = Persons;  &lt;/span&gt;
&lt;span class="c1"&gt;// ChromePdfRenderer renderer = new ChromePdfRenderer();  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocument pdf = renderer.RenderRazorToPdf(this); // 'this' provides current page context  &lt;/span&gt;
&lt;span class="c1"&gt;// Response.Headers.Add("Content-Disposition", "inline; filename=RazorPage.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// return File(pdf.BinaryData, "application/pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// }  &lt;/span&gt;
&lt;span class="c1"&gt;// } &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find &lt;a href="https://ironpdf.com/examples/cshtml-to-pdf-razor/" rel="noopener noreferrer"&gt;code examples for converting Razor Pages to PDF&lt;/a&gt; in their documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blazor Server:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In a Blazor component (.razor file)  &lt;/span&gt;
&lt;span class="c1"&gt;// Requires NuGet package: IronPdf.Extensions.Blazor  &lt;/span&gt;
&lt;span class="c1"&gt;// @using IronPdf  &lt;/span&gt;
&lt;span class="c1"&gt;// @inject IJSRuntime JSRuntime // For download if needed  &lt;/span&gt;
&lt;span class="c1"&gt;// List&amp;lt;PersonInfo&amp;gt; persons = new List&amp;lt;PersonInfo&amp;gt;();   &lt;/span&gt;
&lt;span class="c1"&gt;// Populate data  &lt;/span&gt;
&lt;span class="c1"&gt;// Dictionary&amp;lt;string, object&amp;gt; parameters = new Dictionary&amp;lt;string, object&amp;gt; { { "persons", persons } };  &lt;/span&gt;
&lt;span class="c1"&gt;// private async Task GeneratePdf()  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// ChromePdfRenderer renderer = new ChromePdfRenderer();  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocument pdf = renderer.RenderRazor ComponentToPdf&amp;lt;MyBlazorComponent&amp;gt;(parameters);  &lt;/span&gt;
&lt;span class="c1"&gt;// // To download the PDF in Blazor Server:  &lt;/span&gt;
&lt;span class="c1"&gt;// var pdfBytes = pdf.BinaryData;  &lt;/span&gt;
&lt;span class="c1"&gt;// var fileName = "BlazorComponent.pdf";  &lt;/span&gt;
&lt;span class="c1"&gt;// await JSRuntime.Invoke VoidAsync("Blazor DownloadFile", fileName, "application/pdf", pdfBytes);  &lt;/span&gt;
&lt;span class="c1"&gt;// }  &lt;/span&gt;
&lt;span class="c1"&gt;// // MyBlazorComponent.razor would be the component being rendered.  &lt;/span&gt;
&lt;span class="c1"&gt;// // Blazor Download File is a helper JavaScript function.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Blazor applications, IronPDF offers examples on &lt;a href="https://ironpdf.com/examples/razor-to-pdf-blazor-server/" rel="noopener noreferrer"&gt;converting Razor Components to PDF&lt;/a&gt;. Explanation: IronPDF offers dedicated &lt;a href="https://ironpdf.com/licensing/extensions/" rel="noopener noreferrer"&gt;extension packages&lt;/a&gt; for ASP.NET MVC, Razor Pages, and Blazor, simplifying the process of rendering views or components directly to PDF, including passing model data.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Rendering Options (General HTML to PDF):&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Rendering&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PdfPaperSize, PdfPaperOrientation, PdfCssMediaType  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Engines.Chrome&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For FitToPaperModes  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RenderingOptions&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ChromePdfRenderOptions&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;PaperSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfPaperSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;PaperOrientation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfPaperOrientation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Landscape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;MarginTop&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Millimeters  &lt;/span&gt;
    &lt;span class="n"&gt;MarginBottom&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Millimeters  &lt;/span&gt;
    &lt;span class="n"&gt;PrintHtmlBackgrounds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;EnableJavaScript&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;RenderDelay&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TimeSpan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Wait 1 second for JavaScript to execute  &lt;/span&gt;
    &lt;span class="n"&gt;CssMediaType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfCssMediaType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Screen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Use screen styles  &lt;/span&gt;
    &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"My Custom Document Title"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;FitToPaperMode&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FitToPaperModes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Zoom&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Example of fitting content  &lt;/span&gt;
    &lt;span class="c1"&gt;// For responsive designs, set a virtual viewport width; \[see viewport example\](https://ironpdf.com/examples/viewport/)  &lt;/span&gt;
    &lt;span class="n"&gt;ViewPortWidth&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1280&lt;/span&gt;   
    &lt;span class="c1"&gt;// renderer.RenderingOptions.PaperFit.UseResponsiveCssRendering(1280); // Alternative way for viewport   &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_WithOptions.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;ChromePdfRenderOptions&lt;/code&gt; class provides extensive control over the PDF output, including paper size, orientation, margins, HTML backgrounds, JavaScript execution (with optional delay), CSS media type, PDF title, and content fitting modes. You can find detailed examples on how to &lt;a href="https://ironpdf.com/examples/pdf-generation-settings/" rel="noopener noreferrer"&gt;specify PDF rendering settings&lt;/a&gt;. Asynchronous methods like &lt;code&gt;RenderHtmlAsPdfAsync&lt;/code&gt; are also available, which is useful for non-blocking operations in server environments; see their &lt;a href="https://ironpdf.com/examples/async/" rel="noopener noreferrer"&gt;asynchronous conversion example&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;While IronPDF's primary strength is HTML-to-PDF, it can create blank documents and add content, often by rendering HTML snippets or using stamping features.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Blank PDF:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// Creates a PDF with a blank page of 270x270 points  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;270&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;270&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Blank Page.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example shows how to &lt;a href="https://ironpdf.com/examples/create-blank-page/" rel="noopener noreferrer"&gt;create a blank page PDF&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Text (Directly):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Direct text drawing primitives are less common in IronPDF's high-level API compared to rendering HTML. Text is typically added by rendering an HTML string containing the desired text or by &lt;a href="https://ironpdf.com/examples/stamping-new-content/" rel="noopener noreferrer"&gt;using stamping features for new content&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Editing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For HtmlStamper  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PointF  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfDocument&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Creates a document with one blank page  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;htmlStamper&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;HtmlStamper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;p style='font-family:Arial; font-size:16pt; color:blue;'&amp;gt;Hello World, Stamped\!&amp;lt;/p&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// X position in points  &lt;/span&gt;
    &lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Y position in points  &lt;/span&gt;
    &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Top&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Left&lt;/span&gt;  
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Stamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlStamper&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_StampedText.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Images (Directly):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Similar to text, images are often added by rendering HTML containing &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tags or by &lt;a href="https://ironpdf.com/examples/stamping-new-content/" rel="noopener noreferrer"&gt;using image stamping techniques&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Editing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For ImageStamper  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PointF, SizeF  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"existing_document.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Or new PdfDocument();  &lt;/span&gt;
&lt;span class="c1"&gt;// Ensure the first page exists if it's a new document  &lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PageCount&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NewPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;imageStamper&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ImageStamper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"path/to/your/image.png"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   
    &lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   
    &lt;span class="n"&gt;Height&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Optional: specify dimensions, otherwise original size  &lt;/span&gt;
    &lt;span class="n"&gt;Opacity&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// 0-100  &lt;/span&gt;
    &lt;span class="n"&gt;Rotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="m"&gt;15&lt;/span&gt; &lt;span class="c1"&gt;// Degrees  &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Stamp&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imageStamper&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_StampedImage.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Shapes (Lines, Rectangles):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PointF, RectangleF, Color  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;h1&amp;gt;Document with Shapes&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Create or load a PDF  &lt;/span&gt;
&lt;span class="c1"&gt;// Draw a line on the first page (index 0\)  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PointF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PointF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Red&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// pagelndex, startPt, endPt, color, width  &lt;/span&gt;
&lt;span class="c1"&gt;// Draw a rectangle on the first page  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawRectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;RectangleF&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Blue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LightSkyBlue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// pagelndex, rect, borderColor, fillColor, borderWidth  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_WithShapes.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;DrawLine&lt;/code&gt; and &lt;code&gt;DrawRectangle&lt;/code&gt; methods allow for &lt;a href="https://ironpdf.com/how-to/draw-line-and-rectangle/" rel="noopener noreferrer"&gt;adding basic vector shapes like lines and rectangles&lt;/a&gt; to specified pages with control over coordinates, colors, and line widths.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Watermarks (Text/HTML/Image):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Editing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For VerticalAlignment, HorizontalAlignment, HtmlStamper, ImageStamper  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_to_watermark.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// HTML Watermark (simple method)  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ApplyWatermark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;h2 style='color:rgba(255,0,0,0.5);'&amp;gt;DRAFT&amp;lt;/h2&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Middle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="c1"&gt;// For more control, use Stamper (e.g., Image Watermark on all pages)  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;imageWatermark&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ImageStamper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"confidential.png"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;Opacity&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Percentage  &lt;/span&gt;
    &lt;span class="n"&gt;Rotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bottom&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;IsStampBehindContent&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;// Place watermark behind existing content  &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;StampToAllPages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imageWatermark&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Watermarked.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: &lt;code&gt;ApplyWatermark&lt;/code&gt; is convenient for simple &lt;a href="https://ironpdf.com/examples/pdf-watermarking/" rel="noopener noreferrer"&gt;HTML-based watermarks, as shown in this example&lt;/a&gt;. For greater control over text, HTML, or image stamps, including opacity, rotation, layering (behind/in front of content), and precise alignment, the &lt;code&gt;HtmlStamper&lt;/code&gt;, &lt;code&gt;TextStamper&lt;/code&gt;, and &lt;code&gt;ImageStamper&lt;/code&gt; classes are used with &lt;code&gt;ApplyStamp&lt;/code&gt; or &lt;code&gt;StampToAllPages&lt;/code&gt; methods. Further details can be found on &lt;a href="https://ironpdf.com/how-to/stamp-text-image/" rel="noopener noreferrer"&gt;how to stamp text and images on PDFs&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Headers and Footers:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Rendering&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RenderingOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextHeader&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;TextHeaderFooter&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;CenterText&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"My Document - Page {page} of {total-pages}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   
    &lt;span class="n"&gt;Font&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FontTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Arial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;FontSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;DrawDividerLine&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;  
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RenderingOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HtmlFooter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;HtmlHeaderFooter&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;HtmlFragment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;div style='text-align:right; font-size:8pt;'&amp;gt;&amp;lt;em&amp;gt;Generated on: {date} {time}&amp;lt;/em&amp;gt;&amp;lt;/div&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;MaxHeight&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Millimeters  &lt;/span&gt;
    &lt;span class="n"&gt;BaseUrl&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"C:\\assets\\"&lt;/span&gt; &lt;span class="c1"&gt;// If footer HTML uses relative image paths  &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;body&amp;gt;Main page content here.&amp;lt;/body&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_WithHeaders Footers.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: &lt;code&gt;TextHeaderFooter&lt;/code&gt; allows for simple text-based headers/footers with placeholders like &lt;code&gt;{page}&lt;/code&gt; (see how to &lt;a href="https://ironpdf.com/how-to/page-numbers/" rel="noopener noreferrer"&gt;add page numbers&lt;/a&gt;), &lt;code&gt;{total-pages}&lt;/code&gt;, &lt;code&gt;{url}&lt;/code&gt;, &lt;code&gt;{date}&lt;/code&gt;, &lt;code&gt;{time}&lt;/code&gt;, &lt;code&gt;{html-title}&lt;/code&gt;, and &lt;code&gt;{pdf-title}&lt;/code&gt;. &lt;code&gt;HtmlHeaderFooter&lt;/code&gt; enables rich HTML content for headers/footers, also supporting these placeholders and an optional &lt;code&gt;BaseUrl&lt;/code&gt; for assets. An &lt;a href="https://ironpdf.com/examples/html-headers-and-footers/" rel="noopener noreferrer"&gt;example of adding HTML headers and footers&lt;/a&gt; is available.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Page Operations (Merge, Split, Add, Remove, Copy):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;IronPDF provides various methods for &lt;a href="https://ironpdf.com/examples/editing-pdfs/" rel="noopener noreferrer"&gt;editing PDFs, including page operations&lt;/a&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Merge:&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Collections.Generic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"documentA.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"documentB.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;mergedPdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pdf2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;mergedPdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Merged.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="c1"&gt;// Merge a list of PDF documents  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"doc1.pdf"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  
    &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"doc2.pdf"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  
    &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"doc3.pdf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;mergedFromList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfList&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;mergedFromList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Merged FromList.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above demonstrates how to combine multiple PDF documents; a &lt;a href="https://ironpdf.com/examples/merge-pdfs/" rel="noopener noreferrer"&gt;specific merge PDF example&lt;/a&gt; is also available.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Split (Extract Pages):&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;sourcePdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"multi_page_document.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Extract the first page (0-indexed)  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;firstPagePdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sourcePdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CopyPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;firstPagePdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_FirstPage.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Extract pages 2 and 3 (pages are O-indexed, so index 1, count 2\)  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pages2and3Pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sourcePdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CopyPages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pages2and3Pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Pages2-3.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IronPDF allows for &lt;a href="https://ironpdf.com/examples/split-pdf-pages-csharp/" rel="noopener noreferrer"&gt;splitting PDF pages without losing formatting&lt;/a&gt; as shown. Explanation: IronPDF provides straightforward methods like &lt;code&gt;PdfDocument.Merge()&lt;/code&gt; for combining multiple PDF documents and &lt;code&gt;CopyPage()&lt;/code&gt; or &lt;code&gt;CopyPages()&lt;/code&gt; for extracting specific pages into new &lt;code&gt;PdfDocument&lt;/code&gt; objects. Other operations include adding blank pages (&lt;code&gt;pdf.NewPage()&lt;/code&gt;) or removing pages (&lt;code&gt;pdf.RemovePage(index)&lt;/code&gt;).&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Text Extraction/Replacement:&lt;/strong&gt;
&lt;/h5&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Extract all text:&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"readable_document.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;allText&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ExtractAllText&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;allText&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Extract text from a specific page (e.g., first page, index 0\)  &lt;/span&gt;
&lt;span class="c1"&gt;// string textFromPage = pdf.ExtractTextFromPage(0);   &lt;/span&gt;
&lt;span class="c1"&gt;// Console.WriteLine(textFromPage);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This functionality is useful for content retrieval, and you can compare IronPDF's approach to &lt;a href="https://ironpdf.com/blog/compare-to-other-components/extract-text-from-pdf-csharp-itextsharp/" rel="noopener noreferrer"&gt;extracting text from PDFs with iTextSharp&lt;/a&gt; or learn how to &lt;a href="https://ironpdf.com/how-to/csharp-parse-pdf/" rel="noopener noreferrer"&gt;parse PDF content in C# without losing formatting&lt;/a&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Replace text:&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_with_text.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Replace text on all pages  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReplaceTextOnAllPages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Old Confidential Text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"REDACTED"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="c1"&gt;// Replace text on a specific page (e.g., page 2, index 1\)  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.ReplaceTextOnPage(1, "Specific Text on Page 2", "Updated Text");   &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_TextReplaced.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IronPDF provides methods to &lt;a href="https://ironpdf.com/how-to/find-replace-text/" rel="noopener noreferrer"&gt;find and replace text in a PDF&lt;/a&gt;. A &lt;a href="https://ironpdf.com/examples/csharp-replace-text-in-pdf/" rel="noopener noreferrer"&gt;C# code example for replacing text in PDF&lt;/a&gt; is also available. Explanation: Simple and direct methods for extracting all text content or text from specific pages, and for performing text replacement either document-wide or on a page-by-page basis.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Annotations (Add, Retrieve, Edit, Remove):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Annotations&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PointF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Linq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_for_annotations.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Add a text annotation (sticky note)  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;textAnnotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;TextAnnotation&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Page index (0-based)  &lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Review Note"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;Contents&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Please verify this section."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   
    &lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Position in points  &lt;/span&gt;
    &lt;span class="n"&gt;Icon&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TextAnnotation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AnnotationIcon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Comment&lt;/span&gt;   
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Annotations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;textAnnotation&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="c1"&gt;// Retrieve and Edit the first annotation  &lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Annotations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;firstAnnotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TextAnnotation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Annotations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;First&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="n"&gt;firstAnnotation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contents&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Verification complete. Looks good."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Remove an annotation (e.g., the one just added/edited, if it's still the first)  &lt;/span&gt;
&lt;span class="c1"&gt;// if (pdf.Annotations.Any()) pdf.Annotations.RemoveAt(0);   &lt;/span&gt;
&lt;span class="c1"&gt;// Remove all annotations from a specific page  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.Annotations.RemoveAllAnnotationsForPage(0);   &lt;/span&gt;
&lt;span class="c1"&gt;// Remove all annotations in the document  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.Annotations.Clear();   &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Annotated.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: IronPDF supports programmatic &lt;a href="https://ironpdf.com/how-to/annotations/" rel="noopener noreferrer"&gt;addition, retrieval, modification, and removal of annotations&lt;/a&gt;, particularly text annotations, with properties to control their appearance and content.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Forms:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;IronPDF can convert HTML forms into interactive PDF forms and also allows for the programmatic filling of existing PDF form fields, as detailed in these &lt;a href="https://ironpdf.com/examples/form-data/" rel="noopener noreferrer"&gt;C# PDF Forms code examples&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Create from HTML:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RenderingOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreatePdfFormsFromHtml&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;formHtml&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"  
&amp;lt;form&amp;gt;  
First name: &amp;lt;input type='text' name='firstname' /&amp;gt;&amp;lt;br/&amp;gt;  
Last name: &amp;lt;input type='text' name='lastname' /&amp;gt;&amp;lt;br/&amp;gt;  
&amp;lt;input type='checkbox' name='agree' value='yes'&amp;gt; I agree&amp;lt;br/&amp;gt;  
&amp;lt;input type='submit' value='Submit' /&amp;gt;  
&amp;lt;/form&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfWithForm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formHtml&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdfWithForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_HtmlFormToPdf.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Setting &lt;code&gt;CreatePdfFormsFromHtml = true&lt;/code&gt; in &lt;code&gt;RenderingOptions&lt;/code&gt; instructs IronPDF to convert standard HTML form elements (&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;) into their corresponding interactive PDF form fields.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Fill Existing Forms:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"fillable_form.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Fill a text field  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindFormField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"firstname"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Jane"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindFormField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"lastname"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Doe"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// Check a checkbox (typically by setting its value to "Yes" or its export value)  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;consentCheckbox&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindFormField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"consent_checkbox"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;consentCheckbox&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;consentCheckbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Yes"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Or "On", depends on PDF  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_FilledForm.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;PdfDocument.Form&lt;/code&gt; property provides access to form fields, which can be found by name using &lt;code&gt;FindFormField()&lt;/code&gt; and their values set. You can learn more about &lt;a href="https://ironpdf.com/how-to/edit-forms/" rel="noopener noreferrer"&gt;how to fill and edit PDF forms in C#&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Flatten Forms:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"filled_form.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Makes all form fields non-editable, embedding their values  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_FlattenedForm.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;Flatten()&lt;/code&gt; method converts interactive form fields into static content, effectively making the form data part of the page content and no longer editable. For more details, see how to &lt;a href="https://ironpdf.com/how-to/pdf-image-flatten-csharp/" rel="noopener noreferrer"&gt;flatten PDF forms in C#&lt;/a&gt; or &lt;a href="https://ironpdf.com/blog/videos/how-to-flatten-pdf-images-in-csharp-with-ironpdf/" rel="noopener noreferrer"&gt;watch a video tutorial on flattening PDFs&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Security:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;IronPDF provides several features for securing PDF documents, including password protection and metadata control, covered in these &lt;a href="https://ironpdf.com/examples/security-and-metadata/" rel="noopener noreferrer"&gt;security and metadata code examples&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Password Protection &amp;amp; Permissions:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Security&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PdfPrintSecurity  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sensitive_document.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UserPassword&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"UserPass123"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Password to open  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OwnerPassword&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"OwnerPass456"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Password for changing permissions  &lt;/span&gt;
&lt;span class="c1"&gt;// Set permissions  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AllowUserPrinting&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfPrintSecurity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LowResolution&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AllowUserCopyPasteContent&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AllowUserAnnotations&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SecuritySettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AllowUserFormData&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Secured.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: IronPDF allows setting both user and owner passwords. The owner password, when supplied, grants full access, while the user password grants access according to the defined permissions (e.g., printing, copying, annotating).&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Digital Signatures (PFX/P12):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Signing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// using System.Security.Cryptography.X509Certificates; // For X509Certificate2 if loading cert manually  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;h1&amp;gt;Document to be Signed&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Ensure you have a.pfx or.p12 certificate file  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;signature&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfSignature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"path/to/your_certificate.pfx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"your_pfx_password"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="n"&gt;SigningReason&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Contract Agreement"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;SigningLocation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"New York, USA"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="n"&gt;SigningContact&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"contact@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
    &lt;span class="c1"&gt;// Optionally, add a visual signature image  &lt;/span&gt;
    &lt;span class="c1"&gt;// Signaturelmage = new PdfSignaturelmage("path/to/signature_graphic.png", pageNumber, new IronSoftware.Drawing.Rectangle(x,y,w,h))  &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_DigitallySigned.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: &lt;a href="https://ironpdf.com/how-to/signing/" rel="noopener noreferrer"&gt;Digital signatures can be applied to a PDF document in C#&lt;/a&gt; using a PFX or P12 certificate file, as shown in the &lt;a href="https://ironpdf.com/examples/digitally-sign-a-pdf/" rel="noopener noreferrer"&gt;digital signature code examples&lt;/a&gt;. The &lt;code&gt;PdfSignature&lt;/code&gt; object allows specifying details like the reason for signing, location, and contact information. A visual representation of the signature can also be added. You can also find comparisons of IronPDF's signing capabilities with &lt;a href="https://ironpdf.com/blog/compare-to-other-components/questpdf-sign-pdf/" rel="noopener noreferrer"&gt;QuestPDF&lt;/a&gt; and &lt;a href="https://ironpdf.com/blog/compare-to-other-components/pdfsharp-sign-pdf/" rel="noopener noreferrer"&gt;PDFsharp&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Redaction/Sanitization:&lt;/strong&gt;
&lt;/h5&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Redact Text:&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_with_sensitive_text.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RedactTextOnAllPages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SecretProjectCode"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_TextRedacted.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example shows how to redact specific text; for more comprehensive information, see the guide on &lt;a href="https://ironpdf.com/how-to/redact-text/" rel="noopener noreferrer"&gt;how to redact text and regions from PDFs&lt;/a&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Redact Region:&lt;/strong&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronSoftware.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For RectangleF  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_with_sensitive_region.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Define the rectangle: x, y, width, height in points  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;redactionArea&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;RectangleF&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RedactRegionsOnAllPages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;redactionArea&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_RegionRedacted.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to text, specific regions can be redacted, as detailed in the &lt;a href="https://ironpdf.com/how-to/redact-text/" rel="noopener noreferrer"&gt;redaction guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sanitization (Metadata Removal): IronPDF allows for removal of metadata. While a specific "Sanitize Document" method covering all aspects (scripts, hidden layers) isn't explicitly detailed in one go, control over metadata is a part of sanitization. You can find examples related to &lt;a href="https://ironpdf.com/examples/security-and-metadata/" rel="noopener noreferrer"&gt;metadata in the security section&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_with_metadata.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MetaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RemoveMetaDataKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Title"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MetaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Author&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"New Author"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Can also modify metadata  &lt;/span&gt;
&lt;span class="c1"&gt;// To remove all metadata, one might iterate through pdf.MetaData.Keys() and call RemoveMetaDataKey for each.  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_MetadataCleaned.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: IronPDF provides methods to redact specific text occurrences or defined rectangular regions across all or specific pages. Metadata can also be programmatically removed or altered. The broader "Sanitize PDFs" feature encompasses these actions to help remove sensitive information.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Advanced Features:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table of Contents (TOC):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf.Rendering&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RenderingOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TableOfContents&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TableOfContentsTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WithPageNumbers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// The HTML should contain &amp;lt;h1&amp;gt; to &amp;lt;h6&amp;gt; tags which will be used for TOC generation.  &lt;/span&gt;
&lt;span class="c1"&gt;// Optionally, include &amp;lt;div id="ironpdf-toc"&amp;gt;&amp;lt;/div&amp;gt; in your HTML to specify TOC placement.   &lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlWithHeadings&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"  
&amp;lt;h1&amp;gt;Chapter 1&amp;lt;/h1&amp;gt;  
&amp;lt;p&amp;gt;Content for chapter 1...&amp;lt;/p&amp;gt;  
&amp;lt;h2&amp;gt;Section 1.1&amp;lt;/h2&amp;gt;  
&amp;lt;p&amp;gt;Content for section 1.1...&amp;lt;/p&amp;gt;  
&amp;lt;h1&amp;gt;Chapter 2&amp;lt;/h1&amp;gt;  
&amp;lt;p&amp;gt;Content for chapter 2...&amp;lt;/p&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfWithToc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlWithHeadings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdfWithToc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_WithToc.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: IronPDF can automatically &lt;a href="https://ironpdf.com/how-to/table-of-contents/" rel="noopener noreferrer"&gt;generate a hyperlinked table of contents in .NET C#&lt;/a&gt; from H1-H6 tags in the source HTML. The TOC can be placed at the beginning or at a custom location specified by a div with &lt;code&gt;id="ironpdf-toc"&lt;/code&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Bookmarks:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"long_document.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Add a top-level bookmark to the first page (O-indexed)  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bookmarks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddBookMarkAtEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Introduction"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Add a nested bookmark  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;chapter2Bookmark&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bookmarks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddBookMarkAtEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Chapter 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Assuming Chapter 2 starts on page 6  &lt;/span&gt;
&lt;span class="n"&gt;chapter2Bookmark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Children&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddBookMarkAtStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Section 2.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// To remove a bookmark:  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.Bookmarks.RemoveBookMark(chapter2Bookmark);  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Bookmarked.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Bookmarks (outlines) can be added programmatically, including nested structures, to aid navigation. See their &lt;a href="https://ironpdf.com/examples/bookmarks/" rel="noopener noreferrer"&gt;C# PDF Bookmarks code examples&lt;/a&gt; for more details.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Attachments:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For File.ReadAllBytes  &lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ChromePdfRenderer&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;RenderHtmlAsPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;h1&amp;gt;Document with Attachment&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="kt"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;attachmentBytes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReadAllBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"path/to/data.csv"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;PdfAttachment&lt;/span&gt; &lt;span class="n"&gt;attachment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Attachments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAttachment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Dataset.csv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attachmentBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="c1"&gt;// To remove an attachment:  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.Attachments.RemoveAttachment(attachment);   &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_WithAttachment.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Files of various types can be embedded as attachments within the PDF document. You can find a &lt;a href="https://ironpdf.com/examples/csharp-add-attachment-to-pdf/" rel="noopener noreferrer"&gt;C# code example to add attachments to PDF&lt;/a&gt; and learn &lt;a href="https://ironpdf.com/how-to/add-remove-attachments/" rel="noopener noreferrer"&gt;how to add and remove attachments&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF/A &amp;amp; PDF/UA Compliance:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For long-term archiving and accessibility, IronPDF supports PDF/A and PDF/UA standards. Developers can find useful resources including a general overview of &lt;a href="https://ironpdf.com/blog/using-ironpdf/pdfa-compliance/" rel="noopener noreferrer"&gt;PDF/A compliance mechanisms&lt;/a&gt; and a specific &lt;a href="https://ironpdf.com/blog/using-ironpdf/pdf-to-pdfa/" rel="noopener noreferrer"&gt;tutorial on converting PDF to PDF/A in C#&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;PDF/A (Archival):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_for_archival.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Saves as PDF/A-3b compliant document  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAsPdfA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_PdfA_Compliant.pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PdfAVersions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PdfA3b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code demonstrates converting a standard PDF to a PDF/A compliant version; further details on &lt;a href="https://ironpdf.com/how-to/pdfa/" rel="noopener noreferrer"&gt;how to convert to PDF/A or PDF/A-3 in C#&lt;/a&gt; are available.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;PDF/UA (Accessibility):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_for_accessibility.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAsPdfUA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_PdfUA_Compliant.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IronPDF also enables the creation of &lt;a href="https://ironpdf.com/how-to/pdfua/" rel="noopener noreferrer"&gt;PDF/UA standard documents for accessibility with C# and VB&lt;/a&gt;. IronPDF supports saving documents in PDF/A (for long-term archiving, with various versions like PDF/A-1b, PDF/A-2b, PDF/A-3b available) and PDF/UA (for enhanced accessibility) formats.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Performance (Compression, Async):&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Image Compression:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"document_with_large_images.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Compress images to 60% quality  &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CompressImages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="c1"&gt;// Compress images to 90% quality and shrink if displayed smaller than original  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.CompressImages (90, Shrinklmage: true);   &lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SaveAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IronPDF_Compressed.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above shows how to reduce file size by compressing images; more details are in the &lt;a href="https://ironpdf.com/examples/pdf-compression/" rel="noopener noreferrer"&gt;C# PDF compression example&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Asynchronous PDF Generation:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;IronPdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading.Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// public async Task GeneratePdfAsync()  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;// var renderer = new ChromePdfRenderer();  &lt;/span&gt;
&lt;span class="c1"&gt;// var pdf = await renderer.RenderHtmlAsPdfAsync("&amp;lt;h1&amp;gt;Asynchronous PDF Generation&amp;lt;/h1&amp;gt;");  &lt;/span&gt;
&lt;span class="c1"&gt;// pdf.SaveAs("IronPDF_Async.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For non-blocking operations, especially in server environments, IronPDF supports asynchronous PDF generation, as demonstrated in this &lt;a href="https://ironpdf.com/examples/async/" rel="noopener noreferrer"&gt;example of converting HTML to PDF asynchronously&lt;/a&gt;. Explanation: Provides image compression options to reduce file size and asynchronous methods for PDF generation to improve application responsiveness, especially in web or server environments.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;IronPDF consistently promotes its user-friendly API, which is designed for rapid development and integration into.NET projects. The availability of extensive documentation, including an &lt;a href="https://iron-software.github.io/object-reference/ironpdf/2024.4.2/api/" rel="noopener noreferrer"&gt;API Object Reference on GitHub Pages&lt;/a&gt; and the &lt;a href="https://ironpdf.com/object-reference/api/" rel="noopener noreferrer"&gt;official C# PDF Library Documentation on their website&lt;/a&gt;, along with numerous code examples and tutorials (such as the &lt;a href="https://ironpdf.com/blog/using-ironpdf/convert-html-to-pdf-csharp-without-library/" rel="noopener noreferrer"&gt;developer tutorial on converting HTML to PDF in C# without an external library&lt;/a&gt;), further supports this claim. Installation via NuGet (&lt;code&gt;Install-Package IronPdf&lt;/code&gt;) is standard and straightforward. For practical setup guidance, developers can refer to the guide on &lt;a href="https://ironpdf.com/how-to/license-keys/" rel="noopener noreferrer"&gt;applying software license keys&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The library's design philosophy appears to be a "one-stop-shop" for many PDF-related tasks, particularly excelling in HTML-to-PDF conversions by embedding a Chromium engine. This approach ensures high fidelity with modern web standards (HTML5, CSS3, JavaScript), addressing a common challenge where older or less capable HTML-to-PDF converters might struggle with complex layouts or dynamic content. For developers prioritizing quick integration and high-quality rendering from HTML sources, and who are amenable to a commercial license, IronPDF presents a compelling option. The trade-off for this high-level abstraction might be less direct control over the lowest-level PDF structures compared to libraries like iText 7 (a &lt;a href="https://ironpdf.com/blog/compare-to-other-components/pdfsharp-vs-itextsharp-comparison/" rel="noopener noreferrer"&gt;comparison with iTextSharp is available&lt;/a&gt;), should such deep manipulation be required.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;B. iText 7 (Commercial Add-ons / AGPL Open-Source Core)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Overview and Licensing Model:&lt;/p&gt;

&lt;p&gt;iText 7 is the modern iteration of the widely-used iText library (formerly iTextSharp for.NET), known for its powerful and extensive PDF manipulation capabilities in both Java and.NET environments. It features a modular architecture, with a core library (iText Core) and several add-ons such as pdfHTML (for HTML to PDF conversion), pdfSweep (for redaction), and pdfXFA (for XFA form handling).&lt;/p&gt;

&lt;p&gt;The licensing model for iText 7 is dual: iText Core is available under the AGPL (Affero General Public License), which is a copyleft open-source license. For developers or organizations that cannot comply with AGPL terms (e.g., in closed-source commercial applications) or require dedicated support and access to closed-source add-ons, commercial licenses are necessary.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion (via pdfHTML add-on):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This functionality requires the itext.pdfhtml NuGet package. The pdfHTML add-on is designed to convert HTML and CSS content into standards-compliant PDF documents, supporting HTML5 and CSS3. It can leverage the structural information from HTML to create tagged PDFs, PDF/A, or PDF/UA compliant documents.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML String:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7, itext7.pdfhtml  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Html2pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextHtmlToPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConvertHtmlStringToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FileStream&lt;/span&gt; &lt;span class="n"&gt;pdfDest&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;FileStream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FileMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;ConverterProperties&lt;/span&gt; &lt;span class="n"&gt;converterProperties&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ConverterProperties&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
            &lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
            &lt;span class="c1"&gt;// If your HTML has relative paths for images or CSS, set a base URI:  &lt;/span&gt;
            &lt;span class="c1"&gt;// converterProperties.SetBaseUri("file:///C:/path/to/your/assets/");  &lt;/span&gt;
            &lt;span class="n"&gt;HtmlConverter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConvertToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pdfDest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;converterProperties&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// var converter = new ITextHtmlToPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// string html = "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Hello from iText 7 pdfHTML\!&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;";  &lt;/span&gt;
&lt;span class="c1"&gt;// converter.ConvertHtmlStringToPdf(html, "iText7_HtmlToPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;HtmlConverter.ConvertToPdf&lt;/code&gt; method is the primary means for conversion. &lt;code&gt;ConverterProperties&lt;/code&gt; allows for configuration, such as setting a base URI to resolve relative paths for assets like images and CSS files referenced in the HTML. While powerful, some analyses suggest that for highly complex, JavaScript-heavy HTML, its rendering fidelity might not always match that of full browser-engine-based converters.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;iText 7 provides a rich API for programmatic PDF creation.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Text:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout.Element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextCreatePdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreatePdfWithText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfWriter&lt;/span&gt; &lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Paragraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, iText 7\! This is a programmatically created PDF."&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// This also closes the writer and pdf document  &lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var creator = new ITextCreatePdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// creator.CreatePdfWithText("iText7_CreatedPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: A &lt;code&gt;PdfWriter&lt;/code&gt; directs the output, a &lt;code&gt;PdfDocument&lt;/code&gt; represents the PDF structure, and a &lt;code&gt;Document&lt;/code&gt; object is used as a high-level API to add content elements like &lt;code&gt;Paragraph&lt;/code&gt;, &lt;code&gt;Image&lt;/code&gt;, &lt;code&gt;Table&lt;/code&gt;, etc.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Watermarks:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Adding watermarks typically involves iterating through pages and using the low-level &lt;code&gt;PdfCanvas&lt;/code&gt; API to draw text or images.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf.Canvas&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout.Element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout.Properties&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Colors&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Font&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.IO.Font.Constants&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Geom&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Rectangle  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Math.PI  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextWatermarkExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;AddWatermarkToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;watermarkText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Document for high-level operations if needed  &lt;/span&gt;
        &lt;span class="n"&gt;PdfFont&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfFontFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StandardFonts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HELVETICA_BOLD&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;Paragraph&lt;/span&gt; &lt;span class="n"&gt;watermarkParagraph&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Paragraph&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;watermarkText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetFontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetFontColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DeviceGray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LIGHT_GRAY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.5f&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Color and opacity  &lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetNumberOfPages&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;PdfPage&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
            &lt;span class="n"&gt;Rectangle&lt;/span&gt; &lt;span class="n"&gt;pageSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetPageSizeWithRotation&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
            &lt;span class="c1"&gt;// For drawing directly on page canvas (underneath or on top)  &lt;/span&gt;
            &lt;span class="n"&gt;PdfCanvas&lt;/span&gt; &lt;span class="n"&gt;pdfCanvas&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfCanvas&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NewContentStreamBefore&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetResources&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
            &lt;span class="c1"&gt;// Or for drawing on top: new PdfCanvas(page.NewContentStreamAfter(), page.GetResources(), pdfDoc);  &lt;/span&gt;
            &lt;span class="c1"&gt;// Or for drawing on existing canvas: new PdfCanvas(page);  &lt;/span&gt;
            &lt;span class="c1"&gt;// Using high-level Canvas for easier text alignment and rotation  &lt;/span&gt;
            &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Canvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfCanvas&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetPageSize&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;  
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ShowTextAligned&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;watermarkParagraph&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
                    &lt;span class="n"&gt;pageSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetWidth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
                    &lt;span class="n"&gt;pageSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetHeight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
                    &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetPageNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Use page index for ShowTextAligned  &lt;/span&gt;
                    &lt;span class="n"&gt;TextAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CENTER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
                    &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MIDDLE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
                    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PI&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 45 degrees in radians  &lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// This also closes pdfDoc  &lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var watermarker = new ITextWatermarkExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// watermarker.AddWatermarkToPdf("input.pdf", "iText7_Watermarked.pdf", "CONFIDENTIAL");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: This example demonstrates adding a text watermark to all pages. It gets each &lt;code&gt;PdfPage&lt;/code&gt;, creates a &lt;code&gt;PdfCanvas&lt;/code&gt; (here, drawing before existing content), and then uses a layout &lt;code&gt;Canvas&lt;/code&gt; to easily position and rotate the &lt;code&gt;Paragraph&lt;/code&gt; containing the watermark text. Opacity is set on the paragraph's font color.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Modifying Existing Content (e.g., Form Field Appearance):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7, itext7.forms  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms.Fields&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Font&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.IO.Font.Constants&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Collections.Generic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextModifyFormFieldAppearance&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ModifyFields&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDocument&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt; &lt;span class="n"&gt;acroForm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAcroForm&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true to create if not exists  &lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;acroForm&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;IDictionary&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PdfFormField&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;acroForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAllFormFields&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
            &lt;span class="n"&gt;PdfFont&lt;/span&gt; &lt;span class="n"&gt;newFont&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfFontFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StandardFonts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TIMES_ROMAN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
            &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;newFontSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;8f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
            &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fieldEntry&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
            &lt;span class="p"&gt;{&lt;/span&gt;  
                &lt;span class="n"&gt;PdfFormField&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fieldEntry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
                &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newFont&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;SetFontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newFontSize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                &lt;span class="c1"&gt;// For specific field types, you might need to cast and set other properties  &lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var modifier = new ITextModifyFormFieldAppearance();  &lt;/span&gt;
&lt;span class="c1"&gt;// modifier.ModifyFields("form_original.pdf", "iText7_FormFieldsModified.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: iText allows access to PDF AcroForm fields. This example iterates through all form fields and changes their font and font size.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Forms (AcroForms &amp;amp; XFA):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;iText 7 provides robust support for AcroForms. XFA handling is primarily managed by the pdfXFA add-on.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Creating AcroForm Fields (e.g., TextField):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7, itext7.forms  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Layout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms.Fields&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Geom&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Rectangle  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextCreateFormExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreateSimpleForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Optional for adding other layout elements  &lt;/span&gt;
        &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAcroForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true creates form if not present  &lt;/span&gt;
        &lt;span class="c1"&gt;// Create a text field  &lt;/span&gt;
        &lt;span class="n"&gt;Rectangle&lt;/span&gt; &lt;span class="n"&gt;nameRect&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Rectangle&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;750&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;PdfTextFormField&lt;/span&gt; &lt;span class="n"&gt;nameField&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfTextFormField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nameRect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Enter your name"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;nameField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetFontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nameField&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// Add a label using layout Document (optional)  &lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Paragraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Name:"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;SetFixedPosition&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;778&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Page num, x, y, width  &lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var formCreator = new ITextCreateFormExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// formCreator.CreateSimpleForm("iText7_CreatedForm.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: A &lt;code&gt;PdfAcroForm&lt;/code&gt; object is obtained from the &lt;code&gt;PdfDocument&lt;/code&gt;. Specific field types like &lt;code&gt;PdfTextFormField&lt;/code&gt; are created using factory methods (e.g., &lt;code&gt;CreateText&lt;/code&gt;), specifying their position (&lt;code&gt;Rectangle&lt;/code&gt;) and name. Fields are then added to the form.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Filling AcroForm Fields:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7, itext7.forms  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms.Fields&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Collections.Generic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextFillFormExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;FillExistingForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAcroForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true to update existing  &lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;IDictionary&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PdfFormField&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetFormFields&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;TryGetValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;out&lt;/span&gt; &lt;span class="n"&gt;PdfFormField&lt;/span&gt; &lt;span class="n"&gt;nameFieldToSet&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  
            &lt;span class="p"&gt;{&lt;/span&gt;  
                &lt;span class="n"&gt;nameFieldToSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
            &lt;span class="p"&gt;}&lt;/span&gt;  
            &lt;span class="c1"&gt;// Example for a checkbox (export values can vary, e.g., "Yes", "On")  &lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;TryGetValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"agree_checkbox"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;out&lt;/span&gt; &lt;span class="n"&gt;PdfFormField&lt;/span&gt; &lt;span class="n"&gt;agreeFieldToSet&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  
            &lt;span class="p"&gt;{&lt;/span&gt;  
                &lt;span class="n"&gt;agreeFieldToSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Yes"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
            &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var formFiller = new ITextFillFormExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// formFiller.FillExistingForm("fillable_form.pdf", "iText7_FilledForm.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Form fields are accessed via &lt;code&gt;PdfAcroForm.GetFormFields()&lt;/code&gt; and their values are set using the &lt;code&gt;SetValue()&lt;/code&gt; method.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Flattening Forms:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7, itext7.forms  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextFlattenFormExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;FlattenFilledForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PdfAcroForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAcroForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false as we are not creating/modifying fields, just flattening  &lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FlattenFields&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Makes fields non-interactive  &lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var flattener = new ITextFlattenFormExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// flattener.FlattenFilledForm("filled_form.pdf", "iText7_FlattenedForm.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;FlattenFields()&lt;/code&gt; method on the &lt;code&gt;PdfAcroForm&lt;/code&gt; object converts interactive fields into static page content. For XFA forms, the pdfXFA add-on is required for flattening.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Security:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Password Protection (Encryption):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: itext7  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;iText.Kernel.Pdf.Encryption&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For EncryptionConstants  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Encoding  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ITextEncryptPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;EncryptPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;userPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;ownerPassword&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;PdfReader&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;srcPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;WriterProperties&lt;/span&gt; &lt;span class="n"&gt;writerProperties&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;WriterProperties&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="kt"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;userPassBytes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UTF8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="kt"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;ownerPassBytes&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UTF8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ownerPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;writerProperties&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetStandardEncryption&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
            &lt;span class="n"&gt;userPassBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
            &lt;span class="n"&gt;ownerPassBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
            &lt;span class="n"&gt;EncryptionConstants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ALLOW_PRINTING&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;EncryptionConstants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ALLOW_FILL_IN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Example permissions  &lt;/span&gt;
            &lt;span class="n"&gt;EncryptionConstants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ENCRYPTION_AES_256&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Encryption algorithm  &lt;/span&gt;
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;writerProperties&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var encryptor = new ITextEncryptPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// encryptor.EncryptPdf("unencrypted.pdf", "iText7_Encrypted.pdf", "user123", "owner456");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Encryption is applied via &lt;code&gt;WriterProperties&lt;/code&gt; when creating the &lt;code&gt;PdfWriter&lt;/code&gt;. User and owner passwords, permissions (e.g., &lt;code&gt;ALLOW_PRINTING&lt;/code&gt;), and encryption algorithms (e.g., &lt;code&gt;ENCRYPTION_AES_128&lt;/code&gt;, &lt;code&gt;ENCRYPTION_AES_256&lt;/code&gt;) can be specified.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Digital Signatures (including PADES):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;iText 7 provides extensive support for digital signatures, including PADES standards. Implementing this is complex and typically involves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loading a private key and certificate chain (e.g., from a.pfx file).
&lt;/li&gt;
&lt;li&gt;Preparing the PDF document for signing using &lt;code&gt;PdfSigner&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Creating a signature appearance (optional, for visible signatures).
&lt;/li&gt;
&lt;li&gt;Defining an &lt;code&gt;IExternalSignature&lt;/code&gt; implementation to perform the actual cryptographic signing operation.
&lt;/li&gt;
&lt;li&gt;Optionally, integrating a &lt;code&gt;TSAClient&lt;/code&gt; for timestamps.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Conceptual C\# structure for PAdES-B-B level signature  &lt;/span&gt;
&lt;span class="c1"&gt;// Requires itext7, itext7.bouncy-castle-adapter (for BouncyCastle based crypto)  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Kernel.pdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Signatures;  &lt;/span&gt;
&lt;span class="c1"&gt;// using Org.BouncyCastle.Pkcs; // For Pkcs12Store  &lt;/span&gt;
&lt;span class="c1"&gt;// using Org.BouncyCastle.X509; // For X509Certificate  &lt;/span&gt;
&lt;span class="c1"&gt;// using System.IO;  &lt;/span&gt;
&lt;span class="c1"&gt;// using System.Collections.Generic;  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Commons.Bouncycastle.Cert; // For IX509Certificate  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Commons.Bouncycastle.Crypto; // For IPrivateKey  &lt;/span&gt;
&lt;span class="c1"&gt;// public class ITextPadesSigner  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;//     public void SignPdfPades(string src, string dest, string pfxPath, string pfxPassword, string reason, string location)  &lt;/span&gt;
&lt;span class="c1"&gt;//     {  &lt;/span&gt;
&lt;span class="c1"&gt;//         Pkcs12Store pk12 = new Pkcs12Store(new FileStream(pfxPath, FileMode.Open, FileAccess.Read), pfxPassword.ToCharArray());  &lt;/span&gt;
&lt;span class="c1"&gt;//         string alias = null;  &lt;/span&gt;
&lt;span class="c1"&gt;//         foreach (string currentAlias in pk12.Aliases)  &lt;/span&gt;
&lt;span class="c1"&gt;//         {  &lt;/span&gt;
&lt;span class="c1"&gt;//             if (pk12.IsKeyEntry(currentAlias) &amp;amp;&amp;amp; pk12.GetKey(currentAlias).Key.IsPrivate)  &lt;/span&gt;
&lt;span class="c1"&gt;//             {  &lt;/span&gt;
&lt;span class="c1"&gt;//                 alias = currentAlias;  &lt;/span&gt;
&lt;span class="c1"&gt;//                 break;  &lt;/span&gt;
&lt;span class="c1"&gt;//             }  &lt;/span&gt;
&lt;span class="c1"&gt;//         }  &lt;/span&gt;
&lt;span class="c1"&gt;//         IPrivateKey pk = new PrivateKeyBC(pk12.GetKey(alias).Key);  &lt;/span&gt;
&lt;span class="c1"&gt;//         X509CertificateEntry\[\] certChainEntries = pk12.GetCertificateChain(alias);  &lt;/span&gt;
&lt;span class="c1"&gt;//         IX509Certificate\[\] chain = new IX509Certificate\[certChainEntries.Length\];  &lt;/span&gt;
&lt;span class="c1"&gt;//         for (int i=0; i &amp;lt; certChainEntries.Length; i++)  &lt;/span&gt;
&lt;span class="c1"&gt;//         {  &lt;/span&gt;
&lt;span class="c1"&gt;//             chain\[i\] = new X509CertificateBC(certChainEntries\[i\].Certificate);  &lt;/span&gt;
&lt;span class="c1"&gt;//         }  &lt;/span&gt;
&lt;span class="c1"&gt;//         PdfReader reader = new PdfReader(src);  &lt;/span&gt;
&lt;span class="c1"&gt;//         PdfSigner signer = new PdfSigner(reader, new FileStream(dest, FileMode.Create), new StampingProperties().UseAppendMode());  &lt;/span&gt;
&lt;span class="c1"&gt;//         PdfSignatureAppearance appearance = signer.GetSignatureAppearance()  &lt;/span&gt;
&lt;span class="c1"&gt;//             .SetReason(reason)  &lt;/span&gt;
&lt;span class="c1"&gt;//             .SetLocation(location)  &lt;/span&gt;
&lt;span class="c1"&gt;//             .SetReuseAppearance(false); // Create new appearance  &lt;/span&gt;
&lt;span class="c1"&gt;//         // Optionally set image, text, etc. for appearance  &lt;/span&gt;
&lt;span class="c1"&gt;//         // appearance.SetSignatureGraphic (ImageDataFactory.Create("signature_image.png"));  &lt;/span&gt;
&lt;span class="c1"&gt;//         // appearance.SetLayer2Text("Digitally signed by John Doe");  &lt;/span&gt;
&lt;span class="c1"&gt;//         // For PADES, you might need to set the signature standard  &lt;/span&gt;
&lt;span class="c1"&gt;//         // signer.SetCertificationLevel(PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED);  &lt;/span&gt;
&lt;span class="c1"&gt;//         IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256);  &lt;/span&gt;
&lt;span class="c1"&gt;//         // For PADES B-T or higher, a TSAClient would be needed here  &lt;/span&gt;
&lt;span class="c1"&gt;//         // ITsaClient tsaClient = new TsaClientBouncyCastle("http://tsa.example.com");  &lt;/span&gt;
&lt;span class="c1"&gt;//         signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS); // For PADES B-T: signer.SignDetached(pks, chain, null, null, tsaClient, 0, PdfSigner.CryptoStandard.CMS);  &lt;/span&gt;
&lt;span class="c1"&gt;//     }  &lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: This conceptual example outlines the steps. &lt;code&gt;PdfSigner.SignDetached&lt;/code&gt; is used. For PADES, specific configurations regarding signature dictionaries, embedding CRLS/OCSPs, and timestamps (via &lt;code&gt;ITsaClient&lt;/code&gt;) are often necessary for higher conformance levels (B-T, B-LT, B-LTA). iText 7 supports these advanced signing standards.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Advanced Features:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table of Contents:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;iText 7 does not offer a simple, one-line method to automatically generate a TOC from HTML headings in the way some other libraries might. Creating a TOC typically involves a more manual process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;During the first pass of document generation, identify elements (like headings) that should be in the TOC and record their text, level, and page number. This is often done using event handlers (e.g., &lt;code&gt;IEventHandler&lt;/code&gt; attached to &lt;code&gt;PdfDocumentEvent.END_PAGE&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;After all content pages are generated, create new pages at the beginning of the document (or as specified).
&lt;/li&gt;
&lt;li&gt;Iterate through the collected TOC entries and write them to these new pages, creating &lt;code&gt;Paragraphs&lt;/code&gt; and &lt;code&gt;Link&lt;/code&gt; annotations (or &lt;code&gt;GoToActions&lt;/code&gt;) pointing to the respective page numbers/destinations. This process gives full control but requires more coding.&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;PDF/A &amp;amp; PDF/UA Compliance:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;iText Core is designed to support the creation of PDF/A (archiving) and PDF/UA (accessibility) compliant documents. This often involves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Embedding all fonts.
&lt;/li&gt;
&lt;li&gt;Ensuring content is tagged correctly (for PDF/UA and some PDF/A levels).
&lt;/li&gt;
&lt;li&gt;Setting appropriate metadata and output intents.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// For PDF/A (e.g., PDF/A-3b)  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Kernel.pdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Pdfa;  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Kernel.XMP; // For XMP metadata if needed  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Kernel.Pdf.Filespec;  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.IO.Font; // For FontProgramFactory  &lt;/span&gt;
&lt;span class="c1"&gt;// using iText.Layout.Font; // For FontProvider  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfADocument pdfADoc = new PdfADocument(  &lt;/span&gt;
&lt;span class="c1"&gt;//     new PdfWriter(destPath),  &lt;/span&gt;
&lt;span class="c1"&gt;//     PdfAConformanceLevel.PDFA_3B,  &lt;/span&gt;
&lt;span class="c1"&gt;//     new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", new FileStream(iccProfilePath, FileMode.Open, FileAccess.Read))  &lt;/span&gt;
&lt;span class="c1"&gt;// );  &lt;/span&gt;
&lt;span class="c1"&gt;// Document document = new Document(pdfADoc);  &lt;/span&gt;
&lt;span class="c1"&gt;// pdfADoc.SetTagged(); // Required for some PDF/A levels and PDF/UA  &lt;/span&gt;
&lt;span class="c1"&gt;// // Add content, ensuring fonts are embedded  &lt;/span&gt;
&lt;span class="c1"&gt;// document.Close();&lt;/span&gt;

&lt;span class="c1"&gt;// For PDF/UA  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocument pdfDoc = new PdfDocument(new PdfWriter(destPath, new WriterProperties().AddXmpMetadata()));  &lt;/span&gt;
&lt;span class="c1"&gt;// Document document = new Document(pdfDoc);  &lt;/span&gt;
&lt;span class="c1"&gt;// pdfDoc.SetTagged();  &lt;/span&gt;
&lt;span class="c1"&gt;// pdfDoc.GetCatalog().SetLang(new PdfString("en-US"));  &lt;/span&gt;
&lt;span class="c1"&gt;// pdfDoc.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true));  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocumentInfo info = pdfDoc.GetDocumentInfo();  &lt;/span&gt;
&lt;span class="c1"&gt;// info.SetTitle("My Accessible PDF");  &lt;/span&gt;
&lt;span class="c1"&gt;// // Add content with accessibility properties (e.g., alt text for images)  &lt;/span&gt;
&lt;span class="c1"&gt;// document.Close();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;iText 7 is known for its power and flexibility, which can translate to a steeper learning curve compared to libraries that offer simpler, high-level abstractions for common tasks. However, it provides extensive documentation, a knowledge base, and code examples. The API allows for both high-level document construction and low-level PDF object manipulation. The library's strength in standards compliance (PDF/A, PDF/UA, PADES) makes it a go-to choice for enterprise-level applications where adherence to these specifications is paramount. This focus on standards means developers can create documents that are robust, archivable, accessible, and legally binding. However, this capability often necessitates a deeper understanding of the PDF specification itself. The AGPL/Commercial licensing model remains a significant factor for businesses, often leading to the adoption of commercial licenses to avoid AGPL's copyleft provisions or to gain access to the full suite of add-ons and dedicated support. This positions iText 7 as a premium solution, particularly when its advanced features and compliance capabilities are leveraged.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;C. Aspose.PDF for.NET (Commercial)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Overview and Licensing Model:&lt;/p&gt;

&lt;p&gt;Aspose.PDF for.NET is a comprehensive commercial library enabling.NET applications to create, read, write, modify, and convert PDF files without relying on Adobe Acrobat. It is known for its extensive feature set, covering a wide array of PDF processing tasks from basic creation to complex manipulations and conversions. Aspose typically employs a commercial licensing model, often based on developer seats or deployment scenarios, with options for subscriptions that include updates and support.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://ironpdf.com/competitors/aspose-vs-ironpdf/" rel="noopener noreferrer"&gt;Aspose.PDF&lt;/a&gt; for.NET, often in conjunction with Aspose.HTML, supports HTML to PDF conversion.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML String/File (using Aspose.HTML):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.HTML (and Aspose.PDF if saving options are PDF specific)  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Html.Converters&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Html.Saving&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PdfSaveOptions  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeHtmlToPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConvertHtmlStringToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// The second argument to ConvertHTML is the base path for resolving relative URLs in HTML  &lt;/span&gt;
        &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConvertHTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfSaveOptions&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConvertHtmlFileToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlFilePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTMLDocument&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;HTMLDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlFilePath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;PdfSaveOptions&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfSaveOptions&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
            &lt;span class="c1"&gt;// options.JpegQuality = 100; // Example save option  &lt;/span&gt;
            &lt;span class="c1"&gt;// options.PageSetup.AnyPage = new Aspose.Html.Drawing.Page(new Aspose.Html.Drawing.Size(600, 300)); // Custom page size  &lt;/span&gt;
            &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConvertHTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var converter = new AsposeHtmlToPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// converter.ConvertHtmlStringToPdf("&amp;lt;h1&amp;gt;Hello Aspose.PDF from HTML\!&amp;lt;/h1&amp;gt;", "Aspose_HtmlToPdf.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// converter.ConvertHtmlFileToPdf("input.html", "Aspose_HtmlFileToPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;Converter.ConvertHTML&lt;/code&gt; method from &lt;code&gt;Aspose.Html.Converters&lt;/code&gt; is typically used. It can accept an HTML string, a stream, or an &lt;code&gt;HTMLDocument&lt;/code&gt; instance. &lt;code&gt;PdfSaveOptions&lt;/code&gt; allows for customization of the output PDF, such as JPEG quality, page setup, and encryption.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch):&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Text:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf.Text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For TextFragment and Position  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeCreatePdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreatePdfWithText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;Page&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Adds a new page  &lt;/span&gt;
        &lt;span class="n"&gt;TextFragment&lt;/span&gt; &lt;span class="n"&gt;textFragment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;TextFragment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, Aspose.PDF\! This is programmatically added text."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;textFragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Position&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Position&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// X, Y coordinates from bottom-left  &lt;/span&gt;
        &lt;span class="n"&gt;textFragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FontSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;textFragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Font&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FontRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;textFragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ForegroundColor&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Aspose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Paragraphs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;textFragment&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var creator = new AsposeCreatePdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// creator.CreatePdfWithText("Aspose_CreatedPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: PDF documents are built using the &lt;code&gt;Document&lt;/code&gt; class. Content like &lt;code&gt;TextFragment&lt;/code&gt; is added to pages, with properties for positioning, font, size, and color.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Watermarks:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeWatermarkExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;AddImageWatermark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;imagePath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;pdfDocument&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;WatermarkArtifact&lt;/span&gt; &lt;span class="n"&gt;watermark&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;WatermarkArtifact&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imagePath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArtifactHorizontalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArtifactVerticalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Rotation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Opacity&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IsBackground&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Place watermark behind content  &lt;/span&gt;
        &lt;span class="c1"&gt;// Add to a specific page (e.g., the first page)  &lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;Artifacts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;watermark&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Pages are 1-indexed  &lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="c1"&gt;// public void AddTextWatermark(string inputPdfPath, string outputPdfPath, string watermarkText)  &lt;/span&gt;
    &lt;span class="c1"&gt;// {  &lt;/span&gt;
    &lt;span class="c1"&gt;//     Document pdfDocument = new Document(inputPdfPath);  &lt;/span&gt;
    &lt;span class="c1"&gt;//     TextStamp textStamp = new TextStamp(watermarkText);  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.XIndent = 100;  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.YIndent = 400;  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.RotateAngle = 45;  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.Opacity = 0.5;  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.TextState.Font = FontRepository.FindFont("Arial");  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.TextState.FontSize = 72;  &lt;/span&gt;
    &lt;span class="c1"&gt;//     textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);  &lt;/span&gt;
    &lt;span class="c1"&gt;//     if (pdfDocument.Pages.Count &amp;gt; 0\)  &lt;/span&gt;
    &lt;span class="c1"&gt;//     {  &lt;/span&gt;
    &lt;span class="c1"&gt;//         pdfDocument.Pages\[1\].AddStamp(textStamp);  &lt;/span&gt;
    &lt;span class="c1"&gt;//     }  &lt;/span&gt;
    &lt;span class="c1"&gt;//     pdfDocument.Save(outputPdfPath);  &lt;/span&gt;
    &lt;span class="c1"&gt;// }  &lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var watermarker = new AsposeWatermarkExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// watermarker.AddImageWatermark("input.pdf", "Aspose_Watermarked.pdf", "logo.png");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Aspose.PDF uses &lt;code&gt;WatermarkArtifact&lt;/code&gt; for image watermarks and &lt;code&gt;TextStamp&lt;/code&gt; for text-based watermarks. These provide options for image source, text content, alignment, rotation, opacity, and layering.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Text/Image Manipulation:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Aspose.PDF offers capabilities to add, replace, or remove text and images from PDF documents. For instance, &lt;code&gt;PdfContentEditor.ReplaceText&lt;/code&gt; can be used for text replacement.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Forms (AcroForms):&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Creating Form Fields (e.g., TextBoxField):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf.Annotations&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Border, Dash  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeCreateFormExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreateFormWithTextBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;pdfDocument&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;Page&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="c1"&gt;// Create a TextBoxField  &lt;/span&gt;
        &lt;span class="n"&gt;TextBoxField&lt;/span&gt; &lt;span class="n"&gt;textBoxField&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;TextBoxField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Aspose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;730&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// x1,y1,x2,y2 (from bottom-left)  &lt;/span&gt;
        &lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PartialName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"txtName"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Enter name here"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="c1"&gt;// Customize border (optional)  &lt;/span&gt;
        &lt;span class="n"&gt;Border&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Border&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Dash&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Dash&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Dashed border: 1 unit on, 1 unit off  &lt;/span&gt;
        &lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Border&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Aspose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromRgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LightYellow&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Background color  &lt;/span&gt;
        &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;textBoxField&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Adds to the first page by default if page not specified in Add  &lt;/span&gt;
        &lt;span class="n"&gt;pdfDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var formCreator = new AsposeCreateFormExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// formCreator.CreateFormWithTextBox("Aspose_CreatedForm.pdf");&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Form fields like &lt;code&gt;TextBoxField&lt;/code&gt;, &lt;code&gt;RadioButtonField&lt;/code&gt;, etc., are created and added to the document's &lt;code&gt;Form&lt;/code&gt; collection. Properties for naming, default value, appearance (border, color) can be set.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Filling Form Fields:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf.Facades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Form class used for filling  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeFillFormExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;FillPdfForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;inputFormPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputFilledFormPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// Using Aspose.Pdf.Facades.Form for simpler filling  &lt;/span&gt;
        &lt;span class="n"&gt;Form&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputFormPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;outputFilledFormPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FillField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"txtName"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Johnathan Doe"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Assuming 'txtName' is the field name  &lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FillField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"txtEmail"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"john.doe@example.com"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// For a checkbox named "chkAgree", true to check  &lt;/span&gt;
        &lt;span class="c1"&gt;// form.FillField("chkAgree", true);  &lt;/span&gt;
        &lt;span class="c1"&gt;// For a radio button group "gender", select "Male" option  &lt;/span&gt;
        &lt;span class="c1"&gt;// form.FillField("gender", "Male"); // The value should match one of the export values of radio options  &lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Saves to the outputFilledFormPath specified in constructor  &lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var formFiller = new AsposeFillFormExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// formFiller.FillPdfForm("fillable_form.pdf", "Aspose_FilledForm.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;Aspose.Pdf.Facades.Form&lt;/code&gt; class provides convenient &lt;code&gt;FillField&lt;/code&gt; methods to populate various types of form fields by their name. Overloads exist for text, boolean (checkboxes), and integer (for radio button/list selection by index).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Security:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Password Protection (Encryption):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeEncryptPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;EncryptPdfDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;userPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;ownerPassword&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// Encrypt with user and owner passwords, RC4 128-bit encryption, and forbid all privileges  &lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ownerPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DocumentPrivilege&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ForbidAll&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CryptoAlgorithm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RC4x128&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var encryptor = new AsposeEncryptPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// encryptor.EncryptPdfDocument("unsecure.pdf", "Aspose_Encrypted.pdf", "uPass", "oPass");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;Document.Encrypt&lt;/code&gt; method is used to apply password-based security. It allows specifying user and owner passwords, document privileges (e.g., &lt;code&gt;DocumentPrivilege.ForbidAll&lt;/code&gt;, &lt;code&gt;DocumentPrivilege.AllowAll&lt;/code&gt;), and the encryption algorithm (e.g., &lt;code&gt;CryptoAlgorithm.RC4x128&lt;/code&gt;, &lt;code&gt;CryptoAlgorithm.AESx256&lt;/code&gt;).&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Digital Signatures:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Requires NuGet package: Aspose.PDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Aspose.Pdf.Forms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For SignatureField  &lt;/span&gt;
&lt;span class="c1"&gt;// using System.Security.Cryptography.X509Certificates; // For X509Certificate2 if loading from store  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AsposeSignPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;SignPdfWithPfx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pfxPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pfxPassword&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// Create a signature field on the first page  &lt;/span&gt;
        &lt;span class="n"&gt;SignatureField&lt;/span&gt; &lt;span class="n"&gt;signatureField&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;SignatureField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Aspose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signatureField&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Add field to form  &lt;/span&gt;
        &lt;span class="c1"&gt;// Use PKCS7 (PFX) for signing  &lt;/span&gt;
        &lt;span class="n"&gt;PKCS7&lt;/span&gt; &lt;span class="n"&gt;pkcs&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PKCS7&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pfxPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pfxPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// You can set signature appearance properties on pkcs.Appearance or directly on SignatureField  &lt;/span&gt;
        &lt;span class="c1"&gt;// pkcs.Reason = "Document Validation";  &lt;/span&gt;
        &lt;span class="c1"&gt;// pkcs.Location = "Office";  &lt;/span&gt;
        &lt;span class="n"&gt;signatureField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pkcs&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Sign the specific field  &lt;/span&gt;
        &lt;span class="c1"&gt;// Or, using PdfFileSignature for broader document signing  &lt;/span&gt;
        &lt;span class="c1"&gt;// PdfFileSignature pdfSign = new PdfFileSignature(document);  &lt;/span&gt;
        &lt;span class="c1"&gt;// pdfSign.Sign(1, "Reason", "Contact", "Location", true, new Aspose.Pdf.Rectangle(100,100,200,100), pkcs);  &lt;/span&gt;
        &lt;span class="c1"&gt;// pdfSign.Save(outputPdfPath);  &lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPdfPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var signer = new AsposeSignPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// signer.SignPdfWithPfx("unsigned.pdf", "Aspose_Signed.pdf", "mycert.pfx", "cert_password");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Aspose.PDF supports digital signatures using PFX files (&lt;code&gt;PKCS7&lt;/code&gt; class) or certificates from the Windows store. Signatures can be applied to specific signature fields or more broadly to the document. The &lt;code&gt;Aspose.Pdf.Plugins.Signature&lt;/code&gt; offers another way to handle signing operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Advanced Features:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table of Contents:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Aspose.PDF provides a &lt;code&gt;TocGenerator&lt;/code&gt; class for creating tables of contents. This involves instantiating the generator, setting &lt;code&gt;TocOptions&lt;/code&gt;, specifying input and output files, and then processing.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;PDF/A Compliance:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Aspose.PDF supports PDF/A standards, crucial for long-term archiving. Specific API calls for conversion to PDF/A would be found in their detailed documentation.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Page Manipulation:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Extensive capabilities for adding, deleting, merging, splitting, and reordering pages are available.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Aspose.PDF aims to provide an easy-to-use API for common operations, while also offering deep control for complex tasks. As a commercial product, it typically comes with comprehensive documentation, examples, and dedicated support channels. The library's design often involves a rich object model that mirrors PDF structures. Aspose.PDF for.NET positions itself as a high-performance, feature-rich toolkit for.NET developers, aiming to cover nearly all aspects of PDF manipulation. Its strength lies in its comprehensive API that allows for both high-level operations (like simple conversions) and low-level modifications (like direct content stream access or detailed form field customization). This makes it suitable for enterprise applications where a wide range of PDF functionalities might be required over time. The Aspose suite often includes libraries for other document formats (e.g., Aspose.Words, Aspose.Cells), which can be advantageous for organizations needing a unified approach to document processing. While powerful, the breadth of the API can mean a learning curve for mastering all its intricacies. The commercial license is a key consideration, but it often comes with the assurance of regular updates and professional support.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;D. PuppeteerSharp (Open-Source)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Overview and Licensing Model:&lt;/p&gt;

&lt;p&gt;PuppeteerSharp is a.NET port of Google's popular Node.js library, Puppeteer. It allows developers to control headless (or headed) Chrome or Chromium instances, making it exceptionally well-suited for tasks that require accurate browser rendering, such as HTML-to-PDF conversion, web scraping, and automated testing. Being an open-source project, it is typically available under a permissive license like MIT or Apache.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This is PuppeteerSharp's primary strength in the context of PDF generation. It leverages the full power of the Chromium rendering engine.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From HTML String:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: PuppeteerSharp  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;PuppeteerSharp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading.Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PdfAsync path  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PuppeteerHtmlToPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;ConvertHtmlStringToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// Optional: Download a specific Chromium revision if not already present  &lt;/span&gt;
        &lt;span class="c1"&gt;// await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);  &lt;/span&gt;
        &lt;span class="c1"&gt;// Or use: await new BrowserFetcher().DownloadAsync(); for the latest stable version.  &lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Puppeteer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LaunchAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;LaunchOptions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Headless&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;  
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NewPageAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetContentAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PdfAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Saves directly to file  &lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var converter = new PuppeteerHtmlToPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// await converter.ConvertHtmlStringToPdf("&amp;lt;h1&amp;gt;Hello from PuppeteerSharp\!&amp;lt;/h1&amp;gt;", "Puppeteer_HtmlToPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: A browser instance is launched, a new page is created, HTML content is set, and then &lt;code&gt;PdfAsync&lt;/code&gt; generates the PDF.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;From URL:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: PuppeteerSharp  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;PuppeteerSharp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading.Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PuppeteerUrlToPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;ConvertUrlToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// await new BrowserFetcher().DownloadAsync(); // Ensure browser is available  &lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Puppeteer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LaunchAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;LaunchOptions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;Headless&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;  
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NewPageAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GoToAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NavigationOptions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;WaitUntil&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;WaitUntilNavigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Networkidle0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// Wait for network activity to cease  &lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PdfAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var converter = new PuppeteerUrlToPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// await converter.ConvertUrlToPdf("https://example.com", "Puppeteer_UrlToPdf.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Similar to HTML string conversion, but uses &lt;code&gt;GoToAsync&lt;/code&gt; to load a web page. &lt;code&gt;WaitUntil&lt;/code&gt; options can control when the PDF generation occurs (e.g., after the page is fully loaded).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Rendering Options:&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;//... inside an async method after page is loaded...  &lt;/span&gt;
&lt;span class="c1"&gt;// await page.PdfAsync("Puppeteer_WithOptions.pdf", new PdfOptions  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;//     Format = PaperFormat.A4, // e.g., Letter, A4, A3 etc.   &lt;/span&gt;
&lt;span class="c1"&gt;//     PrintBackground = true, // Include background graphics and colors   &lt;/span&gt;
&lt;span class="c1"&gt;//     MarginOptions = new MarginOptions  &lt;/span&gt;
&lt;span class="c1"&gt;//     {  &lt;/span&gt;
&lt;span class="c1"&gt;//         Top = "1cm",  &lt;/span&gt;
&lt;span class="c1"&gt;//         Bottom = "1cm",  &lt;/span&gt;
&lt;span class="c1"&gt;//         Left = "1cm",  &lt;/span&gt;
&lt;span class="c1"&gt;//         Right = "1cm"  &lt;/span&gt;
&lt;span class="c1"&gt;//     },   &lt;/span&gt;
&lt;span class="c1"&gt;//     HeaderTemplate = "&amp;lt;div style='font-size:10px; width:100%; text-align:center;'&amp;gt;My Page Header&amp;lt;/div&amp;gt;",   &lt;/span&gt;
&lt;span class="c1"&gt;//     FooterTemplate = "&amp;lt;div style='font-size:10px; width:100%; text-align:center;'&amp;gt;Page &amp;lt;span class='pageNumber'&amp;gt;&amp;lt;/span&amp;gt; of &amp;lt;span class='totalPages'&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;",   &lt;/span&gt;
&lt;span class="c1"&gt;//     DisplayHeaderFooter = true,   &lt;/span&gt;
&lt;span class="c1"&gt;//     Scale = 0.9m, // Scale of the webpage rendering (e.g., 0.9 for 90%)   &lt;/span&gt;
&lt;span class="c1"&gt;//     Landscape = false,   &lt;/span&gt;
&lt;span class="c1"&gt;//     PageRanges = "1-3, 5", // e.g., "1-5", "1,3,5-7"   &lt;/span&gt;
&lt;span class="c1"&gt;//     // OmitBackground = true // To reduce file size, if backgrounds are not needed  &lt;/span&gt;
&lt;span class="c1"&gt;// });&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: &lt;code&gt;PdfOptions&lt;/code&gt; provides extensive control over the output, including paper format, margins (specified with units like 'cm', 'px'), HTML-based header and footer templates (which can include special classes like &lt;code&gt;pageNumber&lt;/code&gt;, &lt;code&gt;totalPages&lt;/code&gt;, &lt;code&gt;date&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;url&lt;/code&gt;), background printing, scaling, page orientation, and page ranges.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch), Editing, Forms, Security (Native):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;PuppeteerSharp's core competency is browser automation and rendering web content. It does not offer native APIs for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating PDF documents element by element (e.g., drawing shapes, placing text programmatically without HTML).
&lt;/li&gt;
&lt;li&gt;Advanced PDF editing of existing documents (e.g., merging arbitrary PDFs not generated by Puppeteer, splitting pages, directly manipulating PDF objects).
&lt;/li&gt;
&lt;li&gt;Creating or filling interactive PDF forms (AcroForms).
&lt;/li&gt;
&lt;li&gt;Applying PDF-specific security features like password encryption or digital signatures directly through its API. These functionalities would necessitate the use of another, more PDF-centric library in conjunction with PuppeteerSharp if required. The provided snippets focus exclusively on browser control and HTML-to-PDF features like screenshots, JavaScript evaluation, and PDF generation from web content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For developers familiar with JavaScript's Puppeteer or general browser automation concepts, PuppeteerSharp can be relatively straightforward to use, especially for its primary use case of HTML-to-PDF. The API is asynchronous, requiring &lt;code&gt;async/await&lt;/code&gt;. A key initial step is ensuring the Chromium browser is downloaded and available, which &lt;code&gt;BrowserFetcher&lt;/code&gt; can manage. The library is rated 6/10 for ease of use with moderate documentation and support in one comparison. PuppeteerSharp is a highly specialized tool that excels in producing PDFs from web content with exceptional fidelity to how it appears in a Chrome browser. This makes it an excellent choice when the source material is complex HTML, CSS, and JavaScript that other converters might struggle with. Its utility is primarily as a rendering engine. The dependency on a full browser engine can imply greater resource consumption (CPU, memory) and potentially slower cold start times compared to native PDF generation libraries. Therefore, it's best suited for scenarios where rendering accuracy of web content is paramount, and the trade-offs in performance and resource usage are acceptable. For broader PDF manipulation tasks beyond HTML conversion, it would need to be complemented by other libraries.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;E. PDFsharp (Open-Source)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Overview and Licensing Model:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ironpdf.com/blog/compare-to-other-components/pdfsharp-read-pdf/" rel="noopener noreferrer"&gt;PDFsharp&lt;/a&gt; is a well-established open-source.NET library for creating and processing PDF documents programmatically. It is written entirely in C# and has been available for many years, making it a mature option. PDFsharp is distributed under the MIT License, a permissive open-source license that allows for free use in both personal and commercial projects without copyleft restrictions.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;PDFsharp itself does not provide native functionality for converting HTML to PDF. To achieve this, it must be paired with an external HTML rendering library, most commonly HtmlRenderer.PdfSharp (a separate open-source project).&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Using HtmlRenderer.PdfSharp:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: PDFsharp, HtmlRenderer.PdfSharp  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;PdfSharp.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;TheArtOfDev.HtmlRenderer.PdfSharp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// HtmlRenderer.PdfSharp namespace  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PdfSharpHtmlToPdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConvertHtmlStringToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// PdfDocument pdf = PdfGenerator.GeneratePdf(htmlContent, PageSize.A4); // PageSize from PdfSharp.PageSize  &lt;/span&gt;
        &lt;span class="c1"&gt;// For more control with HtmlRenderer:  &lt;/span&gt;
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;PdfGenerator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPdfPages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PdfSharp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PageSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var converter = new PdfSharpHtmlToPdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// converter.ConvertHtmlStringToPdf("&amp;lt;h1&amp;gt;Hello from PDFsharp &amp;amp; HtmlRenderer\!&amp;lt;/h1&amp;gt;", "PdfSharp_HtmlRender.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: HtmlRenderer.PdfSharp parses the HTML and uses PDFsharp's drawing capabilities to render it onto PDF pages. The level of CSS and JavaScript support is dependent on the HtmlRenderer library, which is generally more limited than browser-engine based solutions, particularly for modern CSS3 and complex JavaScript.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;PDFsharp's core strength is its GDI+-like drawing API for programmatic PDF creation.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Text &amp;amp; Graphics:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: PDFsharp  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;PdfSharp.Pdf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;PdfSharp.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For XGraphics, XFont, XBrushes, XRect, XStringFormats  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For Encoding.RegisterProvider  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PdfSharpCreatePdfExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreatePdfWithTextAndShapes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="c1"&gt;// Required for.NET Core/5+ to use certain encodings if not already done application-wide  &lt;/span&gt;
        &lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RegisterProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CodePagesEncodingProvider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instance&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"PDFsharp Sample Document"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Author&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"My Application"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
        &lt;span class="n"&gt;PdfPage&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
        &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromMillimeter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;210&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// A4 width  &lt;/span&gt;
        &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Height&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XUnit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromMillimeter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;297&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// A4 height  &lt;/span&gt;
        &lt;span class="n"&gt;XGraphics&lt;/span&gt; &lt;span class="n"&gt;gfx&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XGraphics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromPdfPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// Draw text  &lt;/span&gt;
        &lt;span class="n"&gt;XFont&lt;/span&gt; &lt;span class="n"&gt;titleFont&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;XFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Verdana"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;XFontStyle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bold&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, PDFsharp\!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;titleFont&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;XBrushes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DarkBlue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;XRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;XStringFormats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TopCenter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;// Draw a rectangle  &lt;/span&gt;
        &lt;span class="n"&gt;XPen&lt;/span&gt; &lt;span class="n"&gt;pen&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;XPen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XColors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Navy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawRectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;XRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="c1"&gt;// Draw an ellipse filled with color  &lt;/span&gt;
        &lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawEllipse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XBrushes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LightSeaGreen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;XRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
        &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var creator = new PdfSharpCreatePdfExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// creator.CreatePdfWithTextAndShapes("PdfSharp_Created.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: An &lt;code&gt;XGraphics&lt;/code&gt; object is obtained from a &lt;code&gt;PdfPage&lt;/code&gt;. This object provides drawing methods (&lt;code&gt;DrawString&lt;/code&gt;, &lt;code&gt;DrawRectangle&lt;/code&gt;, &lt;code&gt;DrawEllipse&lt;/code&gt;, etc.) similar to &lt;code&gt;System.Drawing.Graphics&lt;/code&gt;. Fonts (&lt;code&gt;XFont&lt;/code&gt;), colors (&lt;code&gt;XBrushes&lt;/code&gt;, &lt;code&gt;XColors&lt;/code&gt;), and pens (&lt;code&gt;XPen&lt;/code&gt;) are used to style the elements. PDFsharp offers fine-grained control over the placement and appearance of graphical elements.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Modifying Existing PDFs (Adding Content, Merging, Splitting):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp can open existing PDF documents for modification, such as adding new content to pages, removing pages, or merging documents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Adding text to an existing PDF's first page  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Pdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Pdf.IO; // For PdfReader  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Drawing;  &lt;/span&gt;
&lt;span class="c1"&gt;// string filePath = "existing_document.pdf";  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfDocument document = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);  &lt;/span&gt;
&lt;span class="c1"&gt;// PdfPage page = document.Pages\[0\]; // Get the first page (O-indexed)  &lt;/span&gt;
&lt;span class="c1"&gt;// XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append); // Append to existing content  &lt;/span&gt;
&lt;span class="c1"&gt;// XFont font = new XFont("Arial", 10, XFontStyle.Italic);  &lt;/span&gt;
&lt;span class="c1"&gt;// gfx.DrawString("Watermark or Appended Text", font, XBrushes.Gray, page.Width/2, page.Height/2, XStringFormats.Center); // Example positioning  &lt;/span&gt;
&lt;span class="c1"&gt;// document.Save("PdfSharp_Modified.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;strong&gt;Watermarks:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Achieved by drawing text or images onto existing or new pages using the &lt;code&gt;XGraphics&lt;/code&gt; object, often with adjusted opacity or layering (using &lt;code&gt;XGraphicsPdfPageOptions.Prepend&lt;/code&gt; or &lt;code&gt;Append&lt;/code&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Forms (AcroForms):&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Creating AcroForm Fields:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp's native support for creating interactive AcroForm fields is very low-level and complex. It does not offer high-level abstractions for easily adding form fields like text boxes or checkboxes. Creating a text field involves manually constructing the underlying PDF dictionary objects, an approach generally not practical for most developers. The term "Form XObjects" or "XForm" in PDFsharp documentation refers to reusable graphical templates, not interactive AcroForms.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Filling AcroForm Fields:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;If a PDF already contains AcroForm fields, PDFsharp can be used to fill them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Conceptual C\# adaptation from VB example  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Pdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Pdf.AcroForms;  &lt;/span&gt;
&lt;span class="c1"&gt;// using PdfSharp.Pdf.IO;  &lt;/span&gt;
&lt;span class="c1"&gt;// public void FillPdfForm(string formPath, string outputPath)  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;//     PdfDocument document = PdfReader.Open(formPath, PdfDocumentOpenMode.Modify);  &lt;/span&gt;
&lt;span class="c1"&gt;//     if (document.AcroForm\!= null)  &lt;/span&gt;
&lt;span class="c1"&gt;//     {  &lt;/span&gt;
&lt;span class="c1"&gt;//         // It's important to set NeedAppearances for some viewers to correctly display values  &lt;/span&gt;
&lt;span class="c1"&gt;//         if (\!document.AcroForm.Elements.ContainsKey("/NeedAppearances"))  &lt;/span&gt;
&lt;span class="c1"&gt;//         {  &lt;/span&gt;
&lt;span class="c1"&gt;//             document.AcroForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));  &lt;/span&gt;
&lt;span class="c1"&gt;//         }  &lt;/span&gt;
&lt;span class="c1"&gt;//         PdfTextField nameField = document.AcroForm.Fields\["txtName"\] as PdfTextField;  &lt;/span&gt;
&lt;span class="c1"&gt;//         if (nameField\!= null)  &lt;/span&gt;
&lt;span class="c1"&gt;//         {  &lt;/span&gt;
&lt;span class="c1"&gt;//             nameField.Value = new PdfString("John Doe");  &lt;/span&gt;
&lt;span class="c1"&gt;//         }  &lt;/span&gt;
&lt;span class="c1"&gt;//         PdfCheckBoxField agreeField = document.AcroForm.Fields\["chkAgree"\] as PdfCheckBoxField;  &lt;/span&gt;
&lt;span class="c1"&gt;//         if (agreeField\!= null)  &lt;/span&gt;
&lt;span class="c1"&gt;//         {  &lt;/span&gt;
&lt;span class="c1"&gt;//             agreeField.Checked = true;  &lt;/span&gt;
&lt;span class="c1"&gt;//         }  &lt;/span&gt;
&lt;span class="c1"&gt;//     }  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.Save(outputPath);  &lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Accessing &lt;code&gt;document.AcroForm.Fields&lt;/code&gt; allows retrieval of fields by name. Values are set using properties like &lt;code&gt;Value&lt;/code&gt; (for text fields) or &lt;code&gt;Checked&lt;/code&gt; (for checkboxes). Setting &lt;code&gt;/NeedAppearances&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; is often crucial.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Security:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Password Protection (Encryption):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp supports setting user and owner passwords, along with document permissions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// using PdfSharp.Pdf;  &lt;/span&gt;
&lt;span class="c1"&gt;// public void EncryptPdf(string outputPath, string userPassword, string ownerPassword)  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;//     PdfDocument document = new PdfDocument();  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.AddPage(); // Add some content  &lt;/span&gt;
&lt;span class="c1"&gt;//     XGraphics gfx = XGraphics.FromPdfPage(document.Pages\[0\]);  &lt;/span&gt;
&lt;span class="c1"&gt;//     gfx.DrawString("This is a secured document.", new XFont("Arial", 12), XBrushes.Black, 50, 50);  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.SecuritySettings.UserPassword = userPassword;  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.SecuritySettings.OwnerPassword = ownerPassword;  &lt;/span&gt;
&lt;span class="c1"&gt;//     // Example: Allow printing but not modifications  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.SecuritySettings.PermitFormsFill = false;  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.SecuritySettings.PermitModifyDocument = false;  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.SecuritySettings.PermitPrint = true;  &lt;/span&gt;
&lt;span class="c1"&gt;//     document.Save(outputPath);  &lt;/span&gt;
&lt;span class="c1"&gt;// }  &lt;/span&gt;
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// EncryptPdf("PdfSharp_Encrypted.pdf", "user123", "owner456");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: The &lt;code&gt;SecuritySettings&lt;/code&gt; property of &lt;code&gt;PdfDocument&lt;/code&gt; is used to set user/owner passwords and define various permissions (e.g., &lt;code&gt;PermitPrint&lt;/code&gt;, &lt;code&gt;PermitModifyDocument&lt;/code&gt;). PDFsharp supports encryption algorithms including AES 256 bit for PDF 2.0.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Digital Signatures:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp has limited native support for applying digital signatures. While it can create signature fields, the actual cryptographic signing process typically requires integration with an external library like Bouncy Castle. The official documentation does not detail a fully native, self-contained digital signature implementation.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Advanced Features:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table of Contents:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp does not provide an automated feature for generating a table of contents from document headings. This would need to be implemented manually by tracking heading positions and creating the TOC pages and links programmatically.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;PDF/A &amp;amp; PDF/UA Compliance:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;PDFsharp version 6.1 and later claim support for PDF/A (archiving) and PDF/UA (accessibility) standards. The specific API usage for ensuring compliance would be detailed in its newer documentation.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;PDFsharp is valued for its simple API for programmatic drawing and basic PDF creation, especially for developers familiar with GDI+. However, the lack of high-level abstractions for more complex tasks like robust HTML-to-PDF conversion or easy AcroForm creation means that achieving these requires more development effort or reliance on third-party extensions. Its open-source nature and MIT license are significant advantages for projects with budget constraints or those requiring source code modification. PDFsharp serves as a foundational open-source library, particularly strong for scenarios where PDFs are constructed programmatically element by element using a drawing-like API. Its reliance on external libraries for functionalities like HTML rendering (e.g., HtmlRenderer.PdfSharp) or advanced digital signatures (e.g., BouncyCastle) positions it more as a core PDF engine rather than an all-in-one solution. The distinction between PDFsharp's "XForm" objects (reusable graphical content) and interactive AcroForms is important; true AcroForm creation is a low-level, manual task with PDFsharp. This makes it a good choice for developers needing fine-grained control over PDF generation at a graphical level or for simpler PDF manipulation tasks where advanced features are either not needed or can be integrated via other means.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;F. QuestPDF (Open-Source with Commercial Tiers)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Overview and Licensing Model:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ironpdf.com/blog/compare-to-other-components/questpdf-html-to-pdf-alternatives/" rel="noopener noreferrer"&gt;QuestPDF&lt;/a&gt; is a modern, open-source.NET library designed for PDF document generation using a declarative C# Fluent API. It emphasizes a code-only approach to defining document structure and layout, aiming for developer productivity and maintainable code. A notable feature is the "QuestPDF Companion App," which offers live preview and hot-reload capabilities during development.&lt;/p&gt;

&lt;p&gt;QuestPDF's licensing model is tiered: it is free for individuals, non-profit organizations, and businesses with annual revenue under $1 million (Community License). For larger organizations or those requiring premium features/support, commercial licenses are available. The underlying open-source code is often associated with the MIT license.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;HTML to PDF Conversion:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Native, direct HTML-to-PDF conversion is not a primary feature of QuestPDF. Its core philosophy revolves around a code-first, fluent API for defining document content and layout. While direct conversion is not built-in, the community has produced extensions like Relorer/HTMLTOQPDF that attempt to parse HTML and map it to QuestPDF elements. However, such extensions typically have limited HTML and CSS support compared to browser-engine-based solutions.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Using Relorer/HTMLTOQPDF Extension (Example):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: QuestPDF, Relorer.QuestPDF.HTML (community extension)  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Fluent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Infrastructure&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Helpers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PageSizes, Colors  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Relorer.QuestPDF.HTML&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// The community extension  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;QuestPdfHtmlConversionExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConvertBasicHtmlToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
            &lt;span class="p"&gt;{&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Margin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Centimetre&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                &lt;span class="p"&gt;{&lt;/span&gt;  
                    &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handler&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;// From Relorer.QuestPDF.HTML  &lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;  
                        &lt;span class="c1"&gt;// Basic HTML support, full CSS/JS not expected  &lt;/span&gt;
                        &lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;htmlContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="c1"&gt;// Example of customizing style for a tag via the extension  &lt;/span&gt;
                        &lt;span class="c1"&gt;// handler.SetTextStyleForHtmlElement("h1", TextStyle.Default.FontSize(20).Bold());  &lt;/span&gt;
                    &lt;span class="p"&gt;});&lt;/span&gt;  
                &lt;span class="p"&gt;});&lt;/span&gt;  
            &lt;span class="p"&gt;});&lt;/span&gt;  
        &lt;span class="p"&gt;})&lt;/span&gt;  
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GeneratePdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var converter = new QuestPdfHtmlConversionExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// converter.ConvertBasicHtmlToPdf("&amp;lt;h1&amp;gt;Hello via QuestPDF HTML Extension&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Some basic text.&amp;lt;/p&amp;gt;", "QuestPDF_HtmlExt.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: This relies on an external community library. The conversion quality and feature support (CSS, JavaScript) are limited by the parser in the extension, not by QuestPDF's native capabilities.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Creation (from scratch using Fluent API):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This is QuestPDF's core strength. Documents are defined by composing elements in C#.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Adding Text, Images, Layouts:&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NuGet: QuestPDF  &lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Fluent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Infrastructure&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;QuestPDF.Helpers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// For PageSizes, Colors, Placeholders  &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;QuestPdfCreateExample&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CreateInvoiceDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="n"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
        &lt;span class="p"&gt;{&lt;/span&gt;  
            &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
            &lt;span class="p"&gt;{&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PageSizes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Margin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Centimetre&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DefaultTextStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;FontFamily&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AlignCenter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Invoice Header"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SemiBold&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;FontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;16&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PaddingVertical&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Centimetre&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;column&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                    &lt;span class="p"&gt;{&lt;/span&gt;  
                        &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Spacing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Customer Name: John Doe"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Placeholders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LoremIpsum&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// Placeholder for more text  &lt;/span&gt;
                        &lt;span class="c1"&gt;// Example of an image (ensure image file exists)  &lt;/span&gt;
                        &lt;span class="c1"&gt;// byte\[\] imageData = File.ReadAllBytes("logo.png");  &lt;/span&gt;
                        &lt;span class="c1"&gt;// column.Item().Image(imageData, ImageScaling.FitArea);  &lt;/span&gt;
                        &lt;span class="c1"&gt;// Example of a simple table  &lt;/span&gt;
                        &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                        &lt;span class="p"&gt;{&lt;/span&gt;  
                            &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ColumnsDefinition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                            &lt;span class="p"&gt;{&lt;/span&gt;  
                                &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConstantColumn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                                &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RelativeColumn&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
                                &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RelativeColumn&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
                            &lt;span class="p"&gt;});&lt;/span&gt;  
                            &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                            &lt;span class="p"&gt;{&lt;/span&gt;  
                                &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Item"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                                &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Quantity"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                                &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Price"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                            &lt;span class="p"&gt;});&lt;/span&gt;  
                            &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Product A"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                            &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;AlignCenter&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                            &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Cell&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;AlignRight&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"$50.00"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="p"&gt;});&lt;/span&gt;  
                    &lt;span class="p"&gt;});&lt;/span&gt;  
                &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Footer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AlignCenter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
                    &lt;span class="p"&gt;{&lt;/span&gt;  
                        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Span&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Page "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CurrentPageNumber&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
                        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Span&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" of "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
                        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;TotalPages&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
                    &lt;span class="p"&gt;});&lt;/span&gt;  
            &lt;span class="p"&gt;});&lt;/span&gt;  
        &lt;span class="p"&gt;})&lt;/span&gt;  
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GeneratePdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="c1"&gt;// Usage:  &lt;/span&gt;
&lt;span class="c1"&gt;// var creator = new QuestPdfCreateExample();  &lt;/span&gt;
&lt;span class="c1"&gt;// creator.CreateInvoiceDocument("QuestPDF_Invoice.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: QuestPDF uses a fluent API to define document structure (&lt;code&gt;Page&lt;/code&gt;, &lt;code&gt;Header&lt;/code&gt;, &lt;code&gt;Content&lt;/code&gt;, &lt;code&gt;Footer&lt;/code&gt;, &lt;code&gt;Column&lt;/code&gt;, &lt;code&gt;Table&lt;/code&gt;, &lt;code&gt;Cell&lt;/code&gt;, &lt;code&gt;Item&lt;/code&gt;) and content (&lt;code&gt;Text&lt;/code&gt;, &lt;code&gt;Image&lt;/code&gt;). It offers rich styling options for text (font, size, color, weight) and layout elements (padding, margin, alignment, background). The API is designed to be intuitive for C# developers.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;QuestPDF's primary focus is PDF generation. While it provides a &lt;code&gt;DocumentOperation&lt;/code&gt; API for some manipulations of existing PDF files, it's not intended for granular content editing within those files.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Watermarks (During Generation):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Watermarks can be added as layers during the document generation process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;//... within Document.Create(container =&amp;gt; { container.Page(page =&amp;gt; {... }); });  &lt;/span&gt;
&lt;span class="c1"&gt;// page.Foreground().Element(watermark =&amp;gt; // Or page.Background() for behind content  &lt;/span&gt;
&lt;span class="c1"&gt;// {  &lt;/span&gt;
&lt;span class="c1"&gt;//     watermark.AlignCenter().AlignMiddle() // Position the watermark  &lt;/span&gt;
&lt;span class="c1"&gt;//         .Rotate(-45) // Rotate -45 degrees  &lt;/span&gt;
&lt;span class="c1"&gt;//         .Text("DRAFT")  &lt;/span&gt;
&lt;span class="c1"&gt;//         .FontColor(Colors.Red.Lighten2) // Set color (can include alpha for opacity)  &lt;/span&gt;
&lt;span class="c1"&gt;//         .FontSize(72)  &lt;/span&gt;
&lt;span class="c1"&gt;//         .SemiBold();  &lt;/span&gt;
&lt;span class="c1"&gt;// });  &lt;/span&gt;
&lt;span class="c1"&gt;// page.Content().Text("This is the main content of the page.");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Watermarks are typically implemented by adding text or image elements to the page's &lt;code&gt;Foreground&lt;/code&gt; or &lt;code&gt;Background&lt;/code&gt; layer, with appropriate styling for rotation, opacity (via color alpha), and positioning.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Merge, Split, Attachments (on existing PDFs via DocumentOperation):&lt;/strong&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// using QuestPDF.Fluent; // For DocumentOperation  &lt;/span&gt;
&lt;span class="c1"&gt;// using QuestPDF.Infrastructure; // For Encryption types etc.  &lt;/span&gt;
&lt;span class="c1"&gt;// // Merge example  &lt;/span&gt;
&lt;span class="c1"&gt;// DocumentOperation  &lt;/span&gt;
&lt;span class="c1"&gt;//     .LoadFile("doc1.pdf")  &lt;/span&gt;
&lt;span class="c1"&gt;//     .MergeFile("doc2.pdf") // Appends doc2.pdf to doc1.pdf  &lt;/span&gt;
&lt;span class="c1"&gt;//     .Save("QuestPDF_Merged.pdf");  &lt;/span&gt;
&lt;span class="c1"&gt;// // Take specific pages and add attachment  &lt;/span&gt;
&lt;span class="c1"&gt;// DocumentOperation  &lt;/span&gt;
&lt;span class="c1"&gt;//     .LoadFile("long_document.pdf")  &lt;/span&gt;
&lt;span class="c1"&gt;//     .TakePages("1-3, 5") // Takes pages 1, 2, 3, and 5  &lt;/span&gt;
&lt;span class="c1"&gt;//     .AddAttachment(new DocumentAttachment { FilePath = "data.xml", MimeType = "application/xml" })  &lt;/span&gt;
&lt;span class="c1"&gt;//     .Save("QuestPDF_PartialWithAttachment.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Forms (Interactive):&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;QuestPDF does not have native support for creating or filling interactive PDF forms (AcroForms). Its design is focused on generating static documents where the content is defined by code.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;PDF Security:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Password Protection (Encryption):&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;QuestPDF supports encrypting PDF documents using its &lt;code&gt;DocumentOperation&lt;/code&gt; API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// using QuestPDF.Fluent;  &lt;/span&gt;
&lt;span class="c1"&gt;// using QuestPDF.Infrastructure; // For Encryption types  &lt;/span&gt;
&lt;span class="c1"&gt;// // Encrypting a newly generated document (conceptual, apply before .GeneratePdf())  &lt;/span&gt;
&lt;span class="c1"&gt;// // Or encrypting an existing document:  &lt;/span&gt;
&lt;span class="c1"&gt;// DocumentOperation  &lt;/span&gt;
&lt;span class="c1"&gt;//     .LoadFile("unencrypted_document.pdf")  &lt;/span&gt;
&lt;span class="c1"&gt;//     .Encrypt(new Encryption256Bit // Or Encryption40Bit, Encryption128Bit  &lt;/span&gt;
&lt;span class="c1"&gt;//     {  &lt;/span&gt;
&lt;span class="c1"&gt;//         UserPassword = "simpleUserPass",  &lt;/span&gt;
&lt;span class="c1"&gt;//         OwnerPassword = "strongOwnerPass123\!",  &lt;/span&gt;
&lt;span class="c1"&gt;//         AllowPrinting = true,  &lt;/span&gt;
&lt;span class="c1"&gt;//         AllowContentExtraction = false,  &lt;/span&gt;
&lt;span class="c1"&gt;//         AllowAnnotation = false,  &lt;/span&gt;
&lt;span class="c1"&gt;//         AllowFillingForms = false, // Though QuestPDF doesn't create forms  &lt;/span&gt;
&lt;span class="c1"&gt;//         EncryptMetadata = true  &lt;/span&gt;
&lt;span class="c1"&gt;//     })  &lt;/span&gt;
&lt;span class="c1"&gt;//     .Save("QuestPDF_Encrypted.pdf");&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation: Encryption can be applied with user and owner passwords, and fine-grained permissions for actions like printing, content extraction, and modification. It supports 40-bit, 128-bit, and 256-bit AES encryption.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Digital Signatures:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;QuestPDF does not offer native support for applying digital signatures to PDF documents. This functionality would require integration with external libraries that specialize in cryptographic operations and PDF signature structures (e.g., BouncyCastle, or using another PDF library for the signing step).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Advanced Features:&lt;/strong&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table of Contents:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Similar to iText 7 and PDFsharp, QuestPDF does not provide an out-of-the-box, automatic TOC generation feature based on document headings. A TOC would need to be constructed manually. This typically involves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generating the main document content. During this process, elements intended for the TOC (e.g., chapter or section titles) and their corresponding page numbers would need to be captured (possibly using section links or by querying element positions after layout).
&lt;/li&gt;
&lt;li&gt;Once all content is laid out and page numbers are known, a new section for the TOC is created (usually at the beginning).
&lt;/li&gt;
&lt;li&gt;The captured TOC entries are then rendered in this section, with text and internal links (using &lt;code&gt;SectionLink&lt;/code&gt; or similar constructs) pointing to the correct pages/locations.&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Attachments:&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;Supported via the &lt;code&gt;DocumentOperation.AddAttachment&lt;/code&gt; method, allowing files to be embedded within the PDF.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Ease of Use and Developer Experience:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;QuestPDF is highly praised for its modern, fluent C# API, which many developers find intuitive and productive, especially those who prefer defining UIs or documents in code. The "code-only" approach facilitates version control, refactoring, and integration with existing C# logic. The QuestPDF Companion App, with its hot-reload and live preview capabilities, significantly enhances the development and debugging experience by allowing developers to see changes in the PDF output almost instantly without recompiling the entire application. The "PDF as Code" philosophy adopted by QuestPDF is its defining characteristic. It empowers.NET developers to use their existing C# skills to construct complex document layouts with programmatic control over every element. This is particularly appealing for generating dynamic, data-driven documents where the structure and content are best expressed through code logic (conditions, loops, data binding). While it excels at generation, its &lt;code&gt;DocumentOperation&lt;/code&gt; API provides useful utilities for post-generation tasks like merging or encrypting existing PDFs. However, it is not designed as a PDF editor for modifying the internal content streams of pre-existing PDF pages. For applications where the primary input is HTML or where deep editing of existing PDF content is required, other libraries would be more suitable. QuestPDF's strength lies in its elegant and powerful generation capabilities from C# code.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;IV. Comparative Analysis and Key Differentiators&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The selection of an appropriate C# PDF library hinges on a nuanced understanding of project requirements, balancing features, ease of use, performance, rendering fidelity, and licensing implications. The six libraries profiled—IronPDF, iText 7, Aspose.PDF for.NET, PuppeteerSharp, PDFsharp, and QuestPDF—each present a distinct value proposition.&lt;/p&gt;

&lt;p&gt;Table 1: C# PDF Library Feature Comparison (2024-2025)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;IronPDF&lt;/th&gt;
&lt;th&gt;iText 7 (Core + pdfHTML)&lt;/th&gt;
&lt;th&gt;Aspose.PDF for.NET&lt;/th&gt;
&lt;th&gt;PuppeteerSharp&lt;/th&gt;
&lt;th&gt;PDFsharp&lt;/th&gt;
&lt;th&gt;QuestPDF&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;License&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Commercial&lt;/td&gt;
&lt;td&gt;AGPL Core / Commercial Add-ons &amp;amp; Core&lt;/td&gt;
&lt;td&gt;Commercial&lt;/td&gt;
&lt;td&gt;Open-Source (e.g., MIT/Apache)&lt;/td&gt;
&lt;td&gt;Open-Source (MIT)&lt;/td&gt;
&lt;td&gt;Open-Source (Community Tier) / Commercial&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTML-to-PDF Engine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Chromium&lt;/td&gt;
&lt;td&gt;iText pdfHTML (custom)&lt;/td&gt;
&lt;td&gt;Proprietary (Aspose.HTML)&lt;/td&gt;
&lt;td&gt;Chromium&lt;/td&gt;
&lt;td&gt;External (e.g., HtmlRenderer.PdfSharp)&lt;/td&gt;
&lt;td&gt;External (Community Ext., e.g., HTMLToQPDF)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTML-to-PDF Fidelity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;10/10 (claimed pixel-perfect)&lt;/td&gt;
&lt;td&gt;Good (can struggle with complex JS/CSS)&lt;/td&gt;
&lt;td&gt;9/10&lt;/td&gt;
&lt;td&gt;9/10 (browser-accurate)&lt;/td&gt;
&lt;td&gt;4/10 (with HtmlRenderer)&lt;/td&gt;
&lt;td&gt;Limited (with community extensions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CSS3 Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Full&lt;/td&gt;
&lt;td&gt;Good (pdfHTML)&lt;/td&gt;
&lt;td&gt;Full (Aspose.HTML)&lt;/td&gt;
&lt;td&gt;Full&lt;/td&gt;
&lt;td&gt;Partial (via HtmlRenderer)&lt;/td&gt;
&lt;td&gt;Limited (via extensions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;JavaScript Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Full (incl. RenderDelay)&lt;/td&gt;
&lt;td&gt;Partial (pdfHTML)&lt;/td&gt;
&lt;td&gt;Full (Aspose.HTML)&lt;/td&gt;
&lt;td&gt;Full&lt;/td&gt;
&lt;td&gt;No (via HtmlRenderer)&lt;/td&gt;
&lt;td&gt;No (via extensions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Direct PDF Creation API&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes (HTML-centric, Stamping)&lt;/td&gt;
&lt;td&gt;Yes (Comprehensive Object Model)&lt;/td&gt;
&lt;td&gt;Yes (Comprehensive Object Model)&lt;/td&gt;
&lt;td&gt;No (HTML/URL input only)&lt;/td&gt;
&lt;td&gt;Yes (GDI+-like Graphics API)&lt;/td&gt;
&lt;td&gt;Yes (Fluent C# API)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Form Creation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTML to Form&lt;/td&gt;
&lt;td&gt;AcroForm API&lt;/td&gt;
&lt;td&gt;AcroForm API&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Very Low-Level / Manual&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Form Filling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;AcroForm &amp;amp; XFA (with pdfXFA)&lt;/td&gt;
&lt;td&gt;AcroForm API&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes (AcroForm)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Form Flattening&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;AcroForm &amp;amp; XFA (with pdfXFA)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Limited (via field properties)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Password Protection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (Browser feature, not PDF lib)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes (DocumentOperation)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Digital Signatures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes (PFX/P12 Native)&lt;/td&gt;
&lt;td&gt;Yes (Native, PAdES)&lt;/td&gt;
&lt;td&gt;Yes (PFX, HSM)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Limited (Requires BouncyCastle)&lt;/td&gt;
&lt;td&gt;No (Requires external libs)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PDF/A Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes (e.g., PDF/A-3b)&lt;/td&gt;
&lt;td&gt;Yes (All levels)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (Browser feature)&lt;/td&gt;
&lt;td&gt;Yes (v6.1+)&lt;/td&gt;
&lt;td&gt;No (Focus on generation, not archiving standards)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PDF/UA Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (Browser feature)&lt;/td&gt;
&lt;td&gt;Yes (v6.1+)&lt;/td&gt;
&lt;td&gt;No (Focus on generation, not accessibility standards)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TOC Generation (Auto)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes (from H1-H6 HTML)&lt;/td&gt;
&lt;td&gt;Manual (Event-based)&lt;/td&gt;
&lt;td&gt;Yes (TocGenerator)&lt;/td&gt;
&lt;td&gt;No (HTML feature)&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ease of Use Rating (1-10)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;9/10&lt;/td&gt;
&lt;td&gt;7/10 (iText Core)&lt;/td&gt;
&lt;td&gt;6/10 (Aspose.PDF)&lt;/td&gt;
&lt;td&gt;6/10&lt;/td&gt;
&lt;td&gt;7/10 (PDFsharp for drawing)&lt;/td&gt;
&lt;td&gt;8-9/10 (Fluent API)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key Strengths&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High-fidelity HTML-to-PDF, Ease of Use, .NET View Rendering&lt;/td&gt;
&lt;td&gt;Standards Compliance, Granular Control, Extensibility&lt;/td&gt;
&lt;td&gt;Rich Feature Set, Enterprise Ready, Document Suite Integration&lt;/td&gt;
&lt;td&gt;Precise Web Rendering, JS Execution&lt;/td&gt;
&lt;td&gt;Lightweight, Programmatic Drawing, Free (MIT)&lt;/td&gt;
&lt;td&gt;Fluent API, Developer Experience, Performance for Generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Notable Limitations&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Commercial&lt;/td&gt;
&lt;td&gt;AGPL for Core, HTML rendering not always perfect for complex JS&lt;/td&gt;
&lt;td&gt;Cost, Complexity for simple tasks&lt;/td&gt;
&lt;td&gt;PDF features beyond HTML rendering limited&lt;/td&gt;
&lt;td&gt;HTML-to-PDF requires external lib, Limited advanced form/signature features&lt;/td&gt;
&lt;td&gt;No native HTML-to-PDF, No interactive forms/signatures&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For a detailed side-by-side visual comparison, see the image &lt;a href="https://drive.google.com/uc?export=download&amp;amp;id=1Ezj0DeId_lwfHkXx87FpiDL7PO68R-_o" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rendering Fidelity and Web Standards Support:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A primary differentiator among these libraries is their approach to HTML-to-PDF conversion. Libraries like IronPDF and PuppeteerSharp utilize embedded Chromium rendering engines. This architecture generally yields the highest fidelity in converting modern HTML5, CSS3, and JavaScript-heavy web pages into PDFs, as they effectively replicate what a user sees in a Chrome browser. This is crucial for applications converting dynamic web reports, dashboards, or user-generated HTML content where visual accuracy is paramount. IronPDF, for example, explicitly markets its "pixel-perfect" rendering, emphasizing its commitment to precise replication.&lt;/p&gt;

&lt;p&gt;iText 7, with its pdfHTML add-on, and Aspose.PDF for .NET (often in conjunction with Aspose.HTML) also provide robust HTML-to-PDF capabilities. While they support modern web standards, their custom rendering engines might occasionally exhibit differences with highly complex or cutting-edge CSS/JavaScript compared to direct browser engine rendering. However, these libraries often provide more granular control over the conversion process itself and offer better integration with their respective comprehensive PDF object models, allowing for deeper manipulation of the resulting PDF structure post-conversion.&lt;/p&gt;

&lt;p&gt;PDFsharp, on the other hand, typically relies on external libraries like HtmlRenderer.PdfSharp for HTML conversion. This approach generally has more limited support for advanced CSS features and complex JavaScript interactions compared to browser-engine based solutions or dedicated HTML-to-PDF components from commercial vendors. QuestPDF, adhering to its code-first philosophy, does not offer native HTML-to-PDF conversion as a core feature, though community-developed extensions might exist that provide basic capabilities for simpler HTML inputs.&lt;/p&gt;

&lt;p&gt;The implication for developers is clear: if the primary input is complex web content requiring the highest degree of visual fidelity, then browser-engine-based libraries such as IronPDF or PuppeteerSharp are strong contenders. If the HTML input is simpler, or if programmatic control over the PDF generation process from HTML is more critical than achieving an exact visual replication of browser rendering, then libraries like iText 7 or Aspose.PDF offer powerful and flexible alternatives, providing a different set of trade-offs between rendering accuracy and control.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;API Design and Ease of Use:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Ease of use is subjective but often correlates with the level of abstraction provided by the API and the clarity of documentation. IronPDF is frequently cited for its user-friendly API, aiming to simplify common tasks into a few lines of code. Its extensions for ASP.NET MVC, Razor Pages, and Blazor further streamline integration for web developers, making it accessible for those already working within the .NET web ecosystem. This focus on developer convenience can significantly reduce development time for common PDF-related tasks.&lt;/p&gt;

&lt;p&gt;QuestPDF stands out with its modern, fluent C# API, which is designed to be intuitive and discoverable, especially for developers accustomed to LINQ-style coding or fluent builder patterns. The QuestPDF Companion App, featuring hot-reload capabilities, significantly enhances the design and debugging experience, allowing for rapid iteration when constructing document layouts. This modern approach can be particularly appealing to developers looking for a more declarative way to define PDFs.&lt;/p&gt;

&lt;p&gt;PDFsharp offers a GDI+-like drawing API that is straightforward for developers with experience in such graphics libraries, making programmatic PDF creation feel natural and familiar. This direct approach to drawing elements can be very powerful for custom layouts. PuppeteerSharp, while powerful for its specific use case of browser automation and HTML rendering, involves asynchronous programming and browser automation concepts. These might present a steeper learning curve for developers new to these paradigms, requiring an understanding of &lt;code&gt;async/await&lt;/code&gt; and browser lifecycles.&lt;/p&gt;

&lt;p&gt;iText 7 and Aspose.PDF for .NET provide very comprehensive APIs, which is a testament to their extensive feature sets. While this allows for immense flexibility and control over every aspect of PDF manipulation, it can also lead to a more complex developer experience for simpler tasks due to the sheer number of classes and options available. However, both libraries typically offer extensive documentation, numerous examples, and dedicated support channels to help developers navigate their rich functionalities and overcome potential complexities.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Feature Set Breadth and Depth:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Commercial libraries like IronPDF, iText 7, and Aspose.PDF for.NET generally offer the most comprehensive feature sets, covering a wide spectrum of PDF functionalities from creation and conversion to advanced editing, forms processing, and security.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iText 7 is particularly strong in standards compliance (PDF/A, PDF/UA), digital signatures (PAdES), and low-level PDF manipulation. Its add-on model allows users to pick specific advanced functionalities like XFA form handling (pdfXFA) or redaction (pdfSweep).
&lt;/li&gt;
&lt;li&gt;Aspose.PDF for.NET also provides a vast array of features, including robust form handling, conversions to and from various formats, and detailed document manipulation capabilities. Its integration with other Aspose libraries for different document types can be an advantage for holistic document management solutions.
&lt;/li&gt;
&lt;li&gt;IronPDF aims to provide a complete suite of commonly needed PDF features with a focus on ease of integration, especially for HTML-to-PDF workflows, and includes strong support for.NET web frameworks. Open-source options vary:
&lt;/li&gt;
&lt;li&gt;PuppeteerSharp is highly specialized for HTML-to-PDF rendering and browser automation, lacking broader PDF manipulation features.
&lt;/li&gt;
&lt;li&gt;PDFsharp offers solid foundational capabilities for PDF creation and basic manipulation but requires external libraries for HTML conversion and has limited native support for advanced interactive forms or digital signatures.
&lt;/li&gt;
&lt;li&gt;QuestPDF excels in programmatic PDF generation with a fluent API and includes operations on existing PDFs like merging and encryption via its &lt;code&gt;DocumentOperation&lt;/code&gt; API, but it does not support interactive form creation/filling or native digital signatures.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance Considerations:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Performance can be a critical factor, especially in high-volume or real-time PDF generation scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser-engine libraries (PuppeteerSharp, IronPDF) can have higher resource consumption and potentially slower cold starts due to the overhead of running a full browser instance. However, for rendering complex web pages, they might be faster overall if the alternative involves intricate manual coding. IronPDF supports asynchronous operations to mitigate blocking in server environments.
&lt;/li&gt;
&lt;li&gt;QuestPDF is designed with performance in mind for its code-based generation, claiming to generate thousands of pages per second with minimal CPU and memory usage.
&lt;/li&gt;
&lt;li&gt;iText 7 and Aspose.PDF for.NET are generally optimized for enterprise workloads, but performance can vary depending on the complexity of the operations.
&lt;/li&gt;
&lt;li&gt;PDFsharp, being lightweight, can be very performant for its core drawing operations but might be bottlenecked by external renderers if used for HTML-to-PDF.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Licensing and Cost:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is a major differentiator.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commercial Libraries (IronPDF, Aspose.PDF for.NET, iText 7 Commercial License): These involve licensing costs, often tiered by&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;V. Conclusion: Navigating the C# PDF Library Landscape for Optimal Outcomes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The journey through the diverse landscape of C# PDF libraries reveals a spectrum of powerful tools, each with its unique strengths tailored to specific developer needs and project requirements. Commercial offerings like iText 7 and Aspose.PDF for .NET provide extensive, enterprise-grade feature sets, excelling in complex PDF manipulations, standards compliance, and deep programmatic control. These libraries are often favored for applications demanding rigorous PDF standards and multifaceted functionalities, forming a robust foundation for enterprise-level document management systems.&lt;/p&gt;

&lt;p&gt;Open-source solutions such as PuppeteerSharp offer unparalleled fidelity in HTML-to-PDF rendering by leveraging browser engines, making it ideal for visually accurate web content conversion. PDFsharp remains a solid choice for its lightweight nature and GDI+-like drawing capabilities for programmatic PDF creation, appealing to developers who need direct control over PDF elements without significant overhead. QuestPDF introduces a modern, fluent API that enhances developer productivity for code-first document generation, providing an intuitive and expressive way to define document structures programmatically.&lt;/p&gt;

&lt;p&gt;However, when considering a holistic solution that balances high-fidelity HTML-to-PDF conversion, a comprehensive feature set, developer experience, and robust support, IronPDF emerges as a particularly compelling option for .NET developers. Its reliance on an embedded Chromium engine ensures that the conversion of modern HTML, CSS, and JavaScript into pixel-perfect PDFs is a core strength. This capability directly addresses a critical need in today's web-centric application development, where accurately capturing the visual output of web technologies is paramount for reports, invoices, and other documents.&lt;/p&gt;

&lt;p&gt;Beyond its technical prowess, IronPDF distinguishes itself with a strong emphasis on the developer ecosystem, aiming to streamline the integration and usage process. The availability of friendly and comprehensive documentation, including MSDN-style API references, quick-start guides, and numerous code examples, significantly flattens the learning curve for new users. This is complemented by what many users find to be an honest pricing model, featuring perpetual licenses and clear tier definitions, which provides transparency and long-term value, allowing businesses to plan their investments effectively.&lt;/p&gt;

&lt;p&gt;Crucially, for development teams where timely assistance is paramount, IronPDF offers better engineer support, with live chat standby 24/5 and direct access to the engineers who built the product. This level of dedicated support, even during trial periods, can be a decisive factor in ensuring project momentum and resolving complex challenges efficiently, minimizing downtime and accelerating development cycles. While the "best" library will always depend on the specific context of a project, IronPDF's combination of advanced HTML rendering, a rich feature set covering the full PDF lifecycle, a user-friendly API, transparent licensing, and exceptional support positions it as a superior all-around choice for many C# development scenarios. To evaluate IronPDF's capabilities firsthand, a &lt;a href="https://ironpdf.com/licensing/" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; is available.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add image to PDF in C# (Developer Tutorial)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 06 Dec 2024 07:24:58 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/how-to-add-image-to-pdf-in-c-developer-tutorial-1665</link>
      <guid>https://dev.to/tayyabcodes/how-to-add-image-to-pdf-in-c-developer-tutorial-1665</guid>
      <description>&lt;p&gt;Every day, millions of businesses rely on &lt;a href="https://en.wikipedia.org/wiki/PDF" rel="noopener noreferrer"&gt;PDF documents&lt;/a&gt; to share information across the globe. The success of these documents often hinges on one key element: images. Clear product photos, informative charts, and precise technical diagrams make the difference between a document that communicates effectively and one that falls flat.&lt;/p&gt;

&lt;p&gt;For .NET developers, handling images in PDF using C# used to be a complex challenge. Traditional methods were clunky and time-consuming, often producing inconsistent results. IronPDF changes this completely. This library gives developers direct control over every aspect of PDF image manipulation - from basic insertion to advanced compression and formatting.&lt;/p&gt;

&lt;p&gt;As companies move away from paper documents, they need reliable tools to create professional digital content. IronPDF fits this need perfectly, offering a straightforward API that works seamlessly with .NET applications. &lt;a href="http://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt; provides the tools to manipulate images with precision and efficiency. It's the kind of practical solution that makes a developer's life easier while ensuring the end product meets professional standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to add Image to a PDF in C
&lt;/h2&gt;

&lt;p&gt;1. Create a C# project in the Visual Studio&lt;/p&gt;

&lt;p&gt;2. Install the PDF library in the project&lt;/p&gt;

&lt;p&gt;3.  Create the PDF document or load the PDF file&lt;/p&gt;

&lt;p&gt;4. Embed the image to the target file&lt;/p&gt;

&lt;p&gt;5. Save the updated PDF file&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;IronPDF: C# PDF Library&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8hab9oq9vbzjg871cwi9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8hab9oq9vbzjg871cwi9.png" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt; is a dot NET library that simplifies PDF handling in C# applications. Unlike complex open-source alternatives, it offers a clean, intuitive API that developers can master quickly. This library handles everything from basic PDF creation to advanced image manipulation, all while maintaining high performance and document fidelity. &lt;/p&gt;

&lt;h3&gt;
  
  
  Key features include:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;PDF generation from HTML, URLs, and images&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Image insertion and extraction capabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Advanced compression algorithms for optimized file sizes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cross-platform support for Windows, Linux, and macOS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thread-safe operations for enterprise applications&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What makes IronPDF stand out is its practical approach to common PDF tasks. Instead of dealing with complex PDF specifications, developers can work with familiar C# objects and methods. This translates to faster development cycles and more reliable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Preparing Your Development Environment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Getting started with IronPDF is straightforward. Here's what you need to do:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Installing IronPDF&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The simplest way to add IronPDF to your project is through NuGet Package Manager. You can either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the Package Manager Console:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Install-Package IronPdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66ojb0pndsfvph302t21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66ojb0pndsfvph302t21.png" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Or use the NuGet Package Manager UI in Visual Studio:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Right-click on your project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select "Manage NuGet Packages"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for "IronPdf"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click Install&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjf3emihekn5gq9es15z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjf3emihekn5gq9es15z.png" width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Setting Up Your Project&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once installed, add these namespace references to your code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
using IronPdf.Editing;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IronPDF works seamlessly with both .NET Framework (4.6.2+) and .NET Core (3.1+) projects. The same API works across platforms, so your code remains consistent whether you're developing for Windows, Linux, or macOS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Image to PDF
&lt;/h2&gt;

&lt;p&gt;When it comes to adding images to PDFs, IronPDF makes it surprisingly simple by leveraging its HTML-to-PDF conversion capabilities. Since IronPDF natively supports converting HTML documents to PDFs, developers can use standard HTML and CSS to include images in their PDFs. This approach not only simplifies image handling but also provides the flexibility of web technologies for layout and styling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use HTML for Image Insertion?
&lt;/h3&gt;

&lt;p&gt;Using HTML to add images to PDFs has several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of Use&lt;/strong&gt;: HTML image tags are straightforward and widely understood.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Precise Layouts&lt;/strong&gt;: CSS allows precise image positioning, size, and styling control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Content&lt;/strong&gt;: HTML is ideal for generating dynamic PDFs with content sourced from databases or user input.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Adding Images to a New PDF Document
&lt;/h3&gt;

&lt;p&gt;You can create a new document and embed images directly into its pages. Using HTML simplifies adding images in various image formats like jpg, png, and jpeg. The following code example demonstrates how to create a new PDF document, embed a bitmap image, and save the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;

class Program
{
    static void Main(string[] args)
    {
        License.LicenseKey = "License-Key";
        // Initialize IronPDF's HTML to PDF renderer
         var renderer = new ChromePdfRenderer();

        // HTML string containing an image
        string html = @"
            &amp;lt;html&amp;gt;
            &amp;lt;body&amp;gt;
                &amp;lt;h1&amp;gt;Welcome to Our PDF&amp;lt;/h1&amp;gt;
                &amp;lt;img src='https://filesamples.com/samples/image/bmp/sample_640%C3%97426.bmp' style='width:300px;height:auto;' /&amp;gt;
            &amp;lt;/body&amp;gt;
            &amp;lt;/html&amp;gt;";

        // Render the HTML to a new PDF document
        PdfDocument pdf = renderer.RenderHtmlAsPdf(html);

        // Save the output file
        pdf.SaveAs("NewDocument.pdf");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7e54h2epel1y0tlgxy2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7e54h2epel1y0tlgxy2l.png" width="757" height="1065"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code creates a new PDF document and inserts an image file at the provided URL. The embedded image can be dynamically loaded or static.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Images to an Existing PDF File
&lt;/h3&gt;

&lt;p&gt;If you need to modify an existing PDF file by adding images to a specific PDF page or creating a new page, IronPDF provides the tools to do so. This example shows how to open an existing PDF file, insert an image onto the first page, and save the modified document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
using IronPdf.Editing;

class Program
{
    static void Main(string[] args)
    {
        License.LicenseKey = "license-key";

        // Load an existing PDF document
        PdfDocument pdf = PdfDocument.FromFile("FileWithImages.pdf");

        // HTML for the source image and additional elements to be added
        string htmlForStamp = @"
            &amp;lt;div style='position: relative;'&amp;gt;
                &amp;lt;p style='color: blue;'&amp;gt;This is a stamped message&amp;lt;/p&amp;gt;
                &amp;lt;img src='https://via.placeholder.com/150' style='width:150px; height:150px;' alt='Sample Image' /&amp;gt;
            &amp;lt;/div&amp;gt;";

        // Create an HtmlStamper for stamping the existing PDF
        HtmlStamper imageStamper = new HtmlStamper(htmlForStamp)
        {
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Bottom,
            VerticalOffset = new Length(50, MeasurementUnit.Points)
        };

        // Apply the stamper to the existing PDF document
        pdf.ApplyStamp(imageStamper);

        // Save the updated PDF file
        pdf.SaveAs("UpdatedDocumentWithImage.pdf");

        System.Console.WriteLine("The PDF has been updated with an image stamp.");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjph4isys9jqnhv0sisd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjph4isys9jqnhv0sisd.png" width="678" height="969"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Extracting Images from PDF Files
&lt;/h3&gt;

&lt;p&gt;IronPDF also enables developers to extract or remove images from PDF documents. You can see all images without opening the PDF file in the folder. Here’s an example of extracting images from a document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
using System.Drawing.Imaging;

class Program
{
    static void Main(string[] args)
    {
        License.LicenseKey = "license-key";

        PdfDocument pdf = PdfDocument.FromFile("PdfWithImages.pdf");

        // Extract images
        var images = pdf.ExtractAllImages();

        for (int i = 0; i &amp;lt; images.Count; i++)
        {
            // Export the extracted images
            images[i].SaveAs($"image{i}.png");
        }

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5icq31yzvvgkdame4gf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5icq31yzvvgkdame4gf.png" width="800" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IronPDF provides .NET developers with a powerful, user-friendly solution for PDF manipulation. Its intuitive API simplifies complex PDF tasks like image insertion, extraction, and document editing across multiple platforms. Whether you're creating dynamic reports, adding visual elements to documents, or processing existing PDFs, IronPDF offers a robust toolkit that makes development easy and ensures professional results.&lt;/p&gt;

&lt;p&gt;For developers looking to explore its capabilities, IronPDF offers a &lt;a href="https://ironpdf.com/licensing/" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; to test the library's features. Licensing options start from $749, providing flexible pricing for different development needs. By choosing IronPDF, developers can save time, reduce complexity, and deliver high-quality PDF solutions with minimal effort.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>tutorial</category>
      <category>ironpdf</category>
      <category>pdf</category>
    </item>
    <item>
      <title>How to Sign PDF File in C# (Developer Tutorial)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Mon, 24 Jun 2024 06:45:32 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/how-to-sign-pdf-file-in-c-developer-tutorial-310f</link>
      <guid>https://dev.to/tayyabcodes/how-to-sign-pdf-file-in-c-developer-tutorial-310f</guid>
      <description>&lt;p&gt;When working with digital documents, &lt;a href="https://support.microsoft.com/en-us/office/digital-signatures-and-certificates-8186cd15-e7ac-4a16-8597-22bd163e8e96#:~:text=A%20digital%20signature%20is%20an,and%20has%20not%20been%20altered." rel="noopener noreferrer"&gt;signing PDFs&lt;/a&gt; is vital for confirming their authenticity and security. Whether it's for contracts, agreements, or important communications, a digital signature verifies the document's origin and integrity. Signed PDF documents are a must-have in this era. Automating this process can save a lot of time, especially when dealing with large volumes of documents.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how to digitally sign a PDF using &lt;a href="https://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt; in C#. This powerful tool makes it easy to add digital signatures to your PDFs programmatically. Let's dive into how you can integrate this functionality of signing a PDF document into your applications, boosting both efficiency and security.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Sign PDF file in C#
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install PDF Library in Visual Studio&lt;/li&gt;
&lt;li&gt;Load PDF file using the PDF library&lt;/li&gt;
&lt;li&gt;Load Digital Signature (e.g. pfx file) &lt;/li&gt;
&lt;li&gt;Apply the Signature to the PDF file using the PDF Library&lt;/li&gt;
&lt;li&gt;Save the signed PDF file&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction of IronPDF Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xsubxs07j2pcfumds08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xsubxs07j2pcfumds08.png" alt="Image description" width="800" height="319"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt; is a comprehensive PDF generation library for the .NET platform, designed to simplify working with PDF documents in C#. Unlike traditional PDF APIs that can be time-consuming, IronPDF leverages HTML, CSS, images, and JavaScript to render high-quality PDFs efficiently. This tool is perfect for developers looking to create, edit, and manipulate PDF documents with minimal hassle.&lt;/p&gt;

&lt;p&gt;Key features of IronPDF include &lt;a href="https://ironpdf.com/examples/using-html-to-create-a-pdf/" rel="noopener noreferrer"&gt;generating PDFs from various sources like HTML&lt;/a&gt; strings, URLs, and ASPX web forms. It supports a wide range of applications, from desktop to web and console applications. The library also offers extensive functionality for editing PDFs, such as adding headers, footers, and watermarks, merging and splitting documents, and securing PDFs with passwords and digital signatures. For this article, we'll focus on IronPDF's capability to add digital signatures to PDFs. This feature allows you to programmatically sign documents.&lt;/p&gt;
&lt;h2&gt;
  
  
  Sign PDF Using IronPDF
&lt;/h2&gt;

&lt;p&gt;With IronPDF, adding digital signatures to your PDF files is straightforward. This section will walk you through installing IronPDF, &lt;a href="https://ironpdf.com/how-to/signing/" rel="noopener noreferrer"&gt;loading a PDF document, and signing it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;IronPDF provides robust features to ensure that your documents are secure and verifiable. You can easily sign PDF documents with digital certificates, set up signature fields for others, and include essential metadata. This flexibility makes IronPDF a valuable tool for industries where document integrity is critical, such as finance and healthcare. Let’s explore how to set up IronPDF and utilize its features to sign your PDF documents effectively.&lt;/p&gt;
&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before you can start signing PDFs with IronPDF, make sure you have the following prerequisites in place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ensure you have a .NET development environment set up. This includes having Visual Studio installed on your machine. You can download Visual Studio from the &lt;a href="https://visualstudio.microsoft.com/" rel="noopener noreferrer"&gt;official website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;A running C# program (Any template)&lt;/li&gt;
&lt;li&gt;Have a sample PDF document ready for testing the signing process. This can be any PDF file you want to experiment with.&lt;/li&gt;
&lt;li&gt;To sign a PDF, you'll need a digital certificate in .pfx or .p12 format. These contain your public/private key pair and are typically issued by a certificate authority. When using X509Certificate2 for loading certificates, make sure to include X509KeyStorageFlags.Exportable. This flag is crucial; without it, IronPDF won't be able to use the private key to apply the signature, and signing will silently fail or throw errors.&lt;/li&gt;
&lt;li&gt;Familiarity with C# programming is essential, as you will be writing code to implement PDF signing functionality.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these prerequisites in place, you'll be ready to use IronPDF to add digital signatures to your PDF documents, ensuring their authenticity and security.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Installing the IronPDF Library
&lt;/h3&gt;

&lt;p&gt;To get started, install the latest stable version of IronPDF (currently 2025.4.4) into your C# project. You can do this using NuGet Package Manager or the Package Manager Console.&lt;/p&gt;
&lt;h4&gt;
  
  
  Recommended Installation via NuGet Console
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install-Package IronPdf -Version 2025.4.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This command pulls the latest stable release (as of now) and automatically adds all necessary dependencies.&lt;/p&gt;
&lt;h4&gt;
  
  
  Dependencies Installed Automatically
&lt;/h4&gt;

&lt;p&gt;When you install IronPDF, the following key dependencies are also included to ensure full functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IronPdf.Native.Chrome.Windows&lt;/strong&gt; – Chrome rendering engine for accurate PDF rendering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IronPdf.Slim&lt;/strong&gt; – Slimmed-down core library for optimized performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IronSoftware.Native.PdfModel&lt;/strong&gt; – Core PDF model library used for internal document structuring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t need to install these separately, they’re pulled in automatically when using the standard NuGet command above.&lt;br&gt;
Once installed, include these in your code file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Load PDF Document
&lt;/h3&gt;

&lt;p&gt;IronPDF supports multiple ways to create or load PDF documents. The most modern approach uses the ChromePdfRenderer class, which lets you render HTML directly into a PDF. This is especially useful when generating content on the fly. Here's how to use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("&amp;lt;h1&amp;gt;Signed PDF&amp;lt;/h1&amp;gt;");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you already have a PDF and just need to load it for signing, you can still use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PdfDocument pdf = PdfDocument.FromFile(pdfPath);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose the method that best fits your use case—whether generating new documents or signing existing ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Load PDF Signature
&lt;/h3&gt;

&lt;p&gt;After loading your PDF document, the next step is to load and configure the digital signature. IronPDF makes this process straightforward. You can load a signature from a PFX file, configure various properties, and apply it to your PDF.&lt;br&gt;
IronPDF offers several ways to apply digital signatures depending on how your certificate is stored. The recommended approach is to use X509Certificate2, especially if you need more control over security. Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Path to your PFX file and its password
string pfxPath = @"C:\path\to\Iron.pfx";
string pfxPassword = "123";
var cert = new X509Certificate2(pfxPath, pfxPassword, X509KeyStorageFlags.Exportable);
var signature = new PdfSignature(cert)
{
    SigningContact = "support@ironsoftware.com",
    SigningLocation = "New York, USA",
    SigningReason = "Security Reasons"
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want a quicker method and are okay with default values, you can directly call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pdf.SignWithFile(pfxPath, pfxPassword);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, to sign using a certificate stored in the Windows Certificate Store:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pdf.SignWithStore("‎ab12cd34ef56...");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After loading and configuring the signature, you can proceed to apply it to your PDF document.&lt;/p&gt;

&lt;h4&gt;
  
  
  Advanced Signature Customization
&lt;/h4&gt;

&lt;p&gt;IronPDF gives you the flexibility to add rich details to your digital signature, helping others verify its origin and purpose. You can include metadata like signing date, reason, and contact info. You can also timestamp the signature using a trusted time server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;signature.SignatureDate = DateTime.UtcNow;
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;
signature.TimeStampUrl = "http://timestamp.digicert.com";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding a visual image, like a scanned signature, boosts credibility:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int imagePageIndex = 0;
int imageX = 50; // Default X coordinate on the page
int imageY = 50; // Default Y coordinate on the page
int imageWidth = 150; // Default image width
int imageHeight = 75;

Rectangle imageRect = new Rectangle(imageX, imageY, imageWidth, imageHeight);

signature.LoadSignatureImageFromFile("signature.png", imagePageIndex, imageRect);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, load it from a stream:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using (FileStream imageStream = new FileStream("signature.png", FileMode.Open, FileAccess.Read))
{
    // Example using AnyBitmap to ensure stream is in a compatible format if needed,
    // though direct stream can work if it's already one of the supported formats.
    // For simplicity, we'll assume the stream from FileStream is directly usable
    // if it's a common format like PNG/JPEG.
    // AnyBitmap anyBmp = AnyBitmap.FromStream(imageStream); // If conversion/validation needed
    // signature.LoadSignatureImageFromStream(anyBmp.ToStream(), imagePageIndex, imageRect);

    signature.LoadSignatureImageFromStream(imageStream, imagePageIndex, imageRect);
    Console.WriteLine("Signature image loaded via LoadSignatureImageFromStream.");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Apply Signature To PDF Document
&lt;/h3&gt;

&lt;p&gt;After loading and configuring your digital signature, the final step is to apply this signature to your PDF document using IronPDF. This step will make your PDF is digitally signed and secure. Here’s how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Apply the signature to the PDF
pdf.Sign(signature);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Signature Permissions
&lt;/h4&gt;

&lt;p&gt;When signing a PDF, IronPDF lets you define what changes, if any, are permitted after the document has been signed. These permissions help preserve document integrity and control what others can do, like filling in forms or adding annotations.&lt;br&gt;
You apply signature permissions during the signing step by passing a SignaturePermissions value into the Sign() method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Sign with permission: allow future form filling and annotations
pdf.Sign(signature, SignaturePermissions.FormFillingAndAnnotationsAllowed);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Available Signature Permissions:
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signature Permission&lt;/th&gt;
&lt;th&gt;What It Allows After Signing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NoChangesAllowed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Completely locks the document.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FormFillingAllowed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Only allows filling in form fields.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FormFillingAndAnnotationsAllowed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows form filling and adding comments/annotations.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AdditionalSignaturesAndFormFillingAllowed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows additional signatures and form filling.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AdditionalSignaturesFormFillingAndAnnotationsAllowed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows all: new signatures, form filling, and annotations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;By setting permissions during signing, you control what future edits are valid. If someone makes a disallowed change, the signature will appear invalid.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Save the Signed PDF File
&lt;/h3&gt;

&lt;p&gt;After applying the digital signature to your PDF document, the final step is to save the signed PDF to a new file. This ensures that your document is securely stored with its new digital signature. Here’s how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Save the signed PDF to a new file
string signedPdfPath = @"C:\path\to\your\signed_document.pdf";
pdf.SaveAs(signedPdfPath);

// Output message to confirm the signing process
Console.WriteLine("PDF signed and saved successfully!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step completes the process of digitally signing a PDF document using IronPDF in C#. Your signed PDF is now saved and ready for use, ensuring its integrity and authenticity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verify PDF Digital Signatures
&lt;/h3&gt;

&lt;p&gt;After running the program, the PDF is signed and saved at the specified path. Below is the screenshot of the signed PDF file. You can see the signature details indicating the document has been successfully signed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8okp077o74r9om2bd3m0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8okp077o74r9om2bd3m0.png" alt="Image description" width="800" height="428"&gt;&lt;/a&gt;&lt;br&gt;
In the screenshot, you can see that the digital signature in the signature field is marked as valid, along with the signing details such as the signer's identity, the location, and the reason for signing. This confirms that the signing process was completed successfully using IronPDF.&lt;/p&gt;
&lt;h3&gt;
  
  
  Complete Code
&lt;/h3&gt;

&lt;p&gt;Here is the complete code for loading, signing, and saving a PDF document using IronPDF in a C# console application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
using IronPdf.Signing;
using System;
using System.Drawing;
using System.IO;
using System.Security.Cryptography.X509Certificates;

class Program
{
    static void Main()
    {
        // Step 1: Load the existing PDF file
        string pdfPath = @"C:\path\to\document.pdf";
        PdfDocument pdf = PdfDocument.FromFile(pdfPath);

        // Step 2: Load the digital certificate from .pfx file
        string pfxPath = @"C:\path\to\Iron.pfx";
        string pfxPassword = "123";

        var cert = new X509Certificate2(pfxPath, pfxPassword, X509KeyStorageFlags.Exportable);

        // Step 3: Create and configure the PDF signature
        var signature = new PdfSignature(cert)
        {
            SigningContact = "support@ironsoftware.com",
            SigningLocation = "New York, USA",
            SigningReason = "Security Reasons",
            SignatureDate = DateTime.UtcNow,
            TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256,
            TimeStampUrl = "http://timestamp.digicert.com"
        };

        // Optional: Add a visual signature image
        int pageIndex = 0;
        Rectangle imageRect = new Rectangle(50, 50, 150, 75); // X, Y, Width, Height
        string imagePath = @"C:\path\to\signature.png";

        if (File.Exists(imagePath))
        {
            signature.LoadSignatureImageFromFile(imagePath, pageIndex, imageRect);
            Console.WriteLine("Visual signature added.");
        }

        // Step 4: Apply the digital signature with permissions
        pdf.Sign(signature, SignaturePermissions.FormFillingAndAnnotationsAllowed);

        // Step 5: Save the signed PDF
        string signedPdfPath = @"C:\path\to\signed_document.pdf";
        pdf.SaveAs(signedPdfPath);

        Console.WriteLine("PDF signed and saved successfully!");
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm02erpzttf3j9rii0ov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm02erpzttf3j9rii0ov.png" alt="Image description" width="800" height="603"&gt;&lt;/a&gt;&lt;br&gt;
In this guide, we walked through the steps to load, sign, and save a PDF document using IronPDF in a C# console application. By following these steps, you can ensure the authenticity and security of your documents through digital signatures. IronPDF simplifies this process, making it accessible even for those new to handling PDF files programmatically.&lt;/p&gt;

&lt;p&gt;IronPDF offers a free trial for developers to explore its features. For long-term use, licenses start at $749, providing access to a robust set of tools for PDF generation and manipulation. For more information and to get started with a &lt;a href="https://ironpdf.com/licensing/" rel="noopener noreferrer"&gt;free trial&lt;/a&gt;, visit the &lt;a href="https://ironpdf.com/" rel="noopener noreferrer"&gt;IronPDF website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>signpdf</category>
      <category>pdflibrary</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Extract Text From PDF in C# (Beginner Tutorial)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Mon, 17 Jun 2024 02:21:24 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/how-to-extract-text-from-pdf-in-c-beginner-tutorial-20li</link>
      <guid>https://dev.to/tayyabcodes/how-to-extract-text-from-pdf-in-c-beginner-tutorial-20li</guid>
      <description>&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/PDF"&gt;PDF&lt;/a&gt; (Portable Document Format) documents have become a standard for sharing and preserving the layout of documents across various platforms and devices. They are widely used due to their ability to maintain formatting, regardless of software or hardware, making them ideal for contracts, manuals, and reports. However, extracting text from a PDF can sometimes be challenging, especially when dealing with complex layouts or embedded content. &lt;/p&gt;

&lt;p&gt;Many PDF libraries in C# provide help in PDF file tasks. In this blog, we’ll dive into the process of extracting text from PDF documents using the &lt;a href="https://ironpdf.com/"&gt;IronPDF library&lt;/a&gt; in C#. IronPDF offers a powerful and user-friendly API that simplifies working with PDFs, allowing developers to retrieve text, images, and other embedded data efficiently. By the end of this guide, you’ll have a clear understanding of how to leverage IronPDF for text extraction in your C# applications, enhancing your ability to manipulate and utilize PDF content effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction of IronPDF Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglqkhm971vt7w72xjqzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglqkhm971vt7w72xjqzo.png" alt="Image description" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ironpdf.com"&gt;IronPDF&lt;/a&gt; is an advanced .NET library that simplifies working with PDF documents. With IronPDF, you can effortlessly create, edit, and manage PDF files within your C# applications. The library uses a Chrome-based rendering engine to convert HTML, CSS, JavaScript, and images into high-quality PDF documents.&lt;/p&gt;

&lt;p&gt;The library provides multiple methods for &lt;a href="https://ironpdf.com/examples/using-html-to-create-a-pdf/"&gt;HTML to PDF conversion&lt;/a&gt;, including creating PDFs from HTML strings, URLs, or MVC views. This flexibility makes it easy to integrate PDF generation into your web applications. Beyond conversion, IronPDF offers extensive features for editing PDF documents. You can add headers, footers, and digital signatures, merge and split PDFs, and even fill and read interactive form data. The library also provides methods to extract data and images from existing PDFs, which is particularly useful for data processing and content manipulation tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extract Text Using IronPDF
&lt;/h2&gt;

&lt;p&gt;With IronPDF, you can easily extract text from any PDF document using a variety of methods tailored to different needs. This section will guide you through the process of installing IronPDF, loading a PDF document, and extracting text using various techniques.&lt;/p&gt;

&lt;p&gt;IronPDF offers robust functionality that simplifies the extraction process, whether you need to retrieve all text, text from specific pages, or text line by line. This flexibility ensures that you can handle various PDF text extraction scenarios efficiently. Let’s explore how to set up IronPDF and use its features to extract text from your PDF documents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1:  Install IronPDF Library
&lt;/h3&gt;

&lt;p&gt;To start using IronPDF in your C# project, you need to install the library via NuGet Package Manager. Open your project in Visual Studio, then follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click on your project in the Solution Explorer.&lt;/li&gt;
&lt;li&gt;Select “Manage NuGet Packages...”&lt;/li&gt;
&lt;li&gt;Search for “IronPDF” in the Browse tab.&lt;/li&gt;
&lt;li&gt;Click “Install” to add the IronPDF library to your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also use NuGet Package manager console for installing IronPDF library using command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install-Package IronPdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, you will have access to the various features IronPDF offers, including PDF creation, editing, and text extraction. Ensure that you have the appropriate directives in your code to utilize IronPDF functionalities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using IronPdf;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup will enable you to efficiently work with PDF documents in your C# applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Load the PDF Document
&lt;/h3&gt;

&lt;p&gt;Before extracting text, you need to load the PDF file into your application. IronPDF makes this process straightforward. Here’s a sample code snippet to load a PDF format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Load the PDF document
var pdf = PdfDocument.FromFile("path/to/your/document.pdf");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code loads the PDF file. Loading the document is the first step towards interacting with its content.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Extract Text from PDF
&lt;/h3&gt;

&lt;p&gt;IronPDF provides several methods to extract PDF text, allowing you to choose the one that best fits your needs.&lt;/p&gt;

&lt;h4&gt;
  
  
  Extract All Text
&lt;/h4&gt;

&lt;p&gt;To extract all the text from a PDF document, you can use the ExtractAllText method. This method returns the entire text content of the PDF as a single string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Extract all text from the PDF
var text = pdf.ExtractAllText();

//Show Extracted text on console
Console.WriteLine(allText);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45y7nvng60c39q1cyb8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45y7nvng60c39q1cyb8r.png" alt="Image description" width="635" height="931"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Extracting all text at once is useful for situations where you need a complete snapshot of the document’s textual content. This method is straightforward and can be used to pull all the text for further processing or analysis quickly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Extract Text from Specific Pages
&lt;/h4&gt;

&lt;p&gt;If you need to extract text from specific pages, you can specify the page numbers. The following example demonstrates how to extract text from the first page of the PDF:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Extract text from specific pages
string text = pdf.ExtractTextFromPage(1);
Console.WriteLine(text);

int[] pages = new[] { 0, 1 };
// Extract text from pages 1 &amp;amp; 2
string pages2 = pdf.ExtractTextFromPages(pages);
Console.WriteLine(pages2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjjkz4154qaw29e3wqlx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjjkz4154qaw29e3wqlx.png" alt="Image description" width="800" height="939"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach is beneficial when you are only interested in certain sections of a document, such as specific chapters in a book or particular sections in a report.&lt;/p&gt;

&lt;h4&gt;
  
  
  Extract Text Line by Line
&lt;/h4&gt;

&lt;p&gt;Extracting text line by line can be useful for more granular text processing. IronPDF provides a method to extract text line by line, ensuring you can process each line individually.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Extract text by lines
var lines = pdf.Pages[1].Lines;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Line-by-line extraction is particularly useful for scenarios where you need to process or analyze text in smaller chunks, such as parsing through each sentence or dealing with formatted data. This method allows for detailed text manipulation, making it easier to handle tasks like data extraction and content analysis.&lt;/p&gt;

&lt;p&gt;By using these methods, you can efficiently extract and manipulate text from your PDF documents in various ways, depending on your requirements. IronPDF’s flexibility and ease of use make it an excellent choice for handling PDF text extraction in your C# applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9vdhf7x3dg0p7gtv0cl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe9vdhf7x3dg0p7gtv0cl.png" alt="Image description" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IronPDF provides a comprehensive and user-friendly solution for working with PDF documents in C#. Its powerful features allow you to easily extract text from PDFs, whether you need all the text at once, specific pages or line by line. &lt;/p&gt;

&lt;p&gt;With IronPDF, you can enhance your application’s capabilities, making tasks like document automation, content management, and data analysis more efficient. Moreover, IronPDF offers a &lt;a href="https://ironpdf.com/licensing/"&gt;free trial&lt;/a&gt;, allowing you to explore its features and see how it fits into your projects. For those looking to integrate IronPDF into their development environment fully, licensing starts at $749, providing access to a wide range of powerful tools and support.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>tutorial</category>
      <category>developer</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How To Edit A Word Documents in C#</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 14 Jun 2024 06:34:30 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/how-to-edit-a-word-documents-in-c-1m2d</link>
      <guid>https://dev.to/tayyabcodes/how-to-edit-a-word-documents-in-c-1m2d</guid>
      <description>&lt;p&gt;&lt;a href="https://www.microsoft.com/en-us/microsoft-365/word"&gt;Word documents&lt;/a&gt; have become a staple in both professional and personal settings. From drafting business reports and academic papers to creating resumes and personal letters, these documents offer a versatile medium for presenting information in a structured and readable format. MS Word allows users to combine text, images, tables, and other elements seamlessly, making them an essential tool for effective communication and documentation.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll dive into the process of editing Word documents using the &lt;a href="https://ironsoftware.com/csharp/word/"&gt;IronWORD library&lt;/a&gt; in C#. Whether you’re looking to automate the creation of documents, update existing files, or manipulate content programmatically, IronWORD provides a robust and easy-to-use API to handle these tasks. We’ll walk you through setting up the IronWORD library, basic operations such as reading and writing text, and more advanced features like formatting, inserting images, and working with tables. By the end of this guide,you’lll be equipped with the knowledge to manage Word documents within your C# applications efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To Edit  Word Documents in C
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a C#  Project in Visual Studio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install C# Word Library using NuGet Package Manager&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create or Load the Word Document&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make Edits in the Word document using Word Library&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the Word file&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction of IronWORD Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajjrxebpwdtatjsalc3h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajjrxebpwdtatjsalc3h.png" alt="Image description" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ironsoftware.com/csharp/word/"&gt;IronWORD&lt;/a&gt; is a powerful C# library designed for developers who need to work with Word documents programmatically within their .NET applications. It simplifies the process of creating, editing, and manipulating new and already existing Word documents, offering a comprehensive API that integrates seamlessly with C#. This tool is particularly useful for automating document workflows, generating reports, and modifying document content dynamically based on various inputs. With IronWORD, developers can handle Word documents without needing Microsoft Word installed on the server or client machines, making it an efficient and lightweight solution for document processing tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features of IronWORD
&lt;/h3&gt;

&lt;p&gt;IronWORD boasts a range of features that cater to different document-handling needs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create and Edit Documents&lt;/strong&gt;: With IronWORD, you can effortlessly create new Word documents or modify existing ones. You can add, delete, and update text, allowing you to handle document content dynamically based on your needs. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply Advanced Formatting&lt;/strong&gt;: IronWORD enables you to change fonts, styles, colors, and paragraph alignment with ease. By applying advanced formatting options, you can ensure that your documents look professional and consistent. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manipulate Tables&lt;/strong&gt;: You can &lt;a href="https://ironsoftware.com/csharp/word/examples/add-table/"&gt;create and edit tables&lt;/a&gt; within your Word documents using IronWORD. This feature allows you to add rows and columns, merge cells, and apply various table styles to organize data effectively. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Insert Images&lt;/strong&gt;: IronWORD allows you to &lt;a href="https://ironsoftware.com/csharp/word/examples/add-image/"&gt;add images to your Word documents&lt;/a&gt; and control their size, alignment, and position. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manage Sections and Pages&lt;/strong&gt;: You can configure sections and pages for advanced layouts using IronWORD. This feature gives you the ability to set different headers and footers for each section and provides more control over the document structure. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these features, IronWORD provides a robust toolkit for developers looking to streamline their document processing workflows in C#.&lt;/p&gt;

&lt;h2&gt;
  
  
  Edit Word Documents Programmatically with IronPDF
&lt;/h2&gt;

&lt;p&gt;Working with Word documents programmatically allows you to automate and streamline your document processing tasks. Using IronWORD, you can create, edit, and manipulate Word documents directly within your C# applications, making it an invaluable tool for developers. Let’s dive into how you can get started with IronWORD to edit Word documents programmatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install IronWORD Library
&lt;/h3&gt;

&lt;p&gt;To begin, you need to install the IronWORD library. This library provides the necessary API to work with Word documents in your C# projects. Follow these steps to install IronWORD:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Visual Studio and create a new C# project or open an existing one.&lt;/li&gt;
&lt;li&gt;Open NuGet Package Manager from the tools menu and search IronWORD in the browse section of NuGet Package Manager.&lt;/li&gt;
&lt;li&gt;Click the“"Instal”" button to add IronWORD to your project.
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33hjuso078ps91z62mi7.png" alt="Image description" width="800" height="458"&gt;
Once the installation is complete, you can start using IronWORD in your application.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Create or Load a Word Document
&lt;/h3&gt;

&lt;p&gt;Loading an existing Word document in C# is a straightforward process with IronWORD. At the top of your Program.cs file, add the following using a directive to include the IronWORD namespace:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;using IronWord;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use the IronWORD API to load an existing Word document. Here is an example code snippet demonstrating how to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Specify the path to the docx file
string filePath = @"C:\path\to\your\document.docx";

// Load the Word document
WordDocument document = WordDocument.FromFile(filePath);

// Now you can start editing the document

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the WordDocument.fromFile method loads the document from the specified file path into a WordDocument object. This object represents the entire document, and you can use it to perform various editing operations. &lt;/p&gt;

&lt;p&gt;If you want to create Word documents and then edit them, you can use the following code snippet to create docx files and start editing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; using IronWord;

// Load docx
WordDocument doc = new WordDocument("NewDocument.docx");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Making Edits in Word Document
&lt;/h3&gt;

&lt;p&gt;Now that you have loaded or created a Word document using IronWORD, you can start making various edits. IronWORD provides a comprehensive set of features to manipulate the document content. Here is a detailed guide on how to perform different types of edits.&lt;/p&gt;

&lt;h4&gt;
  
  
  Add and Format Text
&lt;/h4&gt;

&lt;p&gt;You can add new text to your document and format it to match your desired style. Here is an example of how to add and format text in your document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a new Word document or load an existing one
WordDocument document = new();

Font font = new()
{
    FontFamily = "Arial",
    FontSize = 48
};

TextStyle style = new()
{
    Color = Color.Blue,
    TextFont = font,
    IsBold = true,
    IsItalic = false
};

Text text = new("Welcome to IronWORD")
{
    Style = style,
};

Paragraph paragraph = new Paragraph();

// Add text
paragraph.AddText(text);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mzfpfdh7y6zurkmkskj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mzfpfdh7y6zurkmkskj.png" alt="Image description" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Insert Images
&lt;/h4&gt;

&lt;p&gt;IronWORD allows you to insert images into your document. You can specify theimage’ss dimensions and its placement within the document. Here is how to insert an image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Configure image
IronWord.Models.Image image = new IronWord.Models.Image("F:\\image.png");
image.Width = 400; // In unit pixel
image.Height = 90; // In unit pixel

Paragraph imageParagraph = new Paragraph();

// Add image
imageParagraph.AddImage(image);

// Add paragraph
document.AddParagraph(imageParagraph);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9jsn21szke31zfwpyrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9jsn21szke31zfwpyrx.png" alt="Image description" width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code snippet shows how to insert an image into a document and adjust its size.&lt;/p&gt;

&lt;h4&gt;
  
  
  Manipulate Tables
&lt;/h4&gt;

&lt;p&gt;Creating and editing tables is made easy with IronWORD. You can add rows and columns, set cell values, and apply various styles. Here's an example of how to create and manipulate a table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create table
Table table = new Table(5, 3);

// Configure border style
BorderStyle borderStyle = new BorderStyle();
borderStyle.BorderColor = Color.Blue;
borderStyle.BorderValue = BorderValues.Single;
borderStyle.BorderSize = 2;

// Configure table border
TableBorders tableBorders = new TableBorders()
{
    TopBorder = borderStyle,
    RightBorder = borderStyle,
    BottomBorder = borderStyle,
    LeftBorder = borderStyle,
};

// Apply styling
table.Zebra = new ZebraColor("EEEEEE", "CCCCCC");
table.Borders = tableBorders;

// Populate table with new headers and data
table[0, 0] = new TableCell(new Text("ID"));
table[0, 1] = new TableCell(new Text("Product Name"));
table[0, 2] = new TableCell(new Text("Price"));

table[1, 0] = new TableCell(new Text("1"));
table[1, 1] = new TableCell(new Text("Laptop"));
table[1, 2] = new TableCell(new Text("$999"));

table[2, 0] = new TableCell(new Text("2"));
table[2, 1] = new TableCell(new Text("Smartphone"));
table[2, 2] = new TableCell(new Text("$499"));

table[3, 0] = new TableCell(new Text("3"));
table[3, 1] = new TableCell(new Text("Tablet"));
table[3, 2] = new TableCell(new Text("$299"));

table[4, 0] = new TableCell(new Text("4"));
table[4, 1] = new TableCell(new Text("Smartwatch"));
table[4, 2] = new TableCell(new Text("$199"));

// Add table
document.AddTable(table);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fd7r89yqq8vildapsei.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fd7r89yqq8vildapsei.png" alt="Image description" width="800" height="781"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Save Edited Word Document
&lt;/h4&gt;

&lt;p&gt;Once you have made all the necessary edits to your Word document using IronWORD, the final step is to save your changes. IronWORD makes this process straightforward, allowing you to save the document with a new name or overwrite the existing file. &lt;/p&gt;

&lt;p&gt;After editing the document, use the SaveAs method to save the document. This method allows you to specify the path and name for the saved file. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Save the document with a new name
document.SaveAs(@"C:\path\to\your\edited_document.docx");

//Save the document with same name
document.save();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code snippet shows how to save the document to a specified location with a new name. This is particularly useful if you want to keep the original document unchanged and save the edited version separately.&lt;/p&gt;

&lt;h3&gt;
  
  
  Complete Code
&lt;/h3&gt;

&lt;p&gt;Below is the complete code combining all the steps mentioned above. You can add the code snippets to create, load, edit, and save a Word document using IronWORD.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Add the necessary using directive
using IronWord;
using IronWord.Models;
using IronWord.Models.Enums;

License.LicenseKey = "License-Key";

// Create a new Word document or load an existing one
WordDocument document = new();

Font font = new()

{
    FontFamily = "Arial",

    FontSize = 48
};

TextStyle style = new()
{
    Color = Color.Blue,
    TextFont = font,
    IsBold = true,
    IsItalic = false
};

Text text = new("Welcome to IronWORD")
{
    Style = style,
};

Paragraph paragraph = new Paragraph();

// Add text
paragraph.AddText(text);

// Add paragraph
document.AddParagraph(paragraph);


// Configure image

IronWord.Models.Image image = new IronWord.Models.Image("F:\\image.png");

image.Width = 400; // In unit pixel

image.Height = 90; // In unit pixel

Paragraph imageParagraph = new Paragraph();

// Add image
imageParagraph.AddImage(image);

// Add paragraph

document.AddParagraph(imageParagraph);

// Create table
Table table = new Table(5, 3);

// Configure border style
BorderStyle borderStyle = new BorderStyle();
borderStyle.BorderColor = Color.Blue;
borderStyle.BorderValue = BorderValues.Single;
borderStyle.BorderSize = 2;

// Configure table border
TableBorders tableBorders = new TableBorders()
{
    TopBorder = borderStyle,
    RightBorder = borderStyle,
    BottomBorder = borderStyle,
    LeftBorder = borderStyle,
};

// Apply styling
table.Zebra = new ZebraColor("EEEEEE", "CCCCCC");
table.Borders = tableBorders;

// Populate table with new headers and data
table[0, 0] = new TableCell(new Text("ID"));
table[0, 1] = new TableCell(new Text("Product Name"));
table[0, 2] = new TableCell(new Text("Price"));

table[1, 0] = new TableCell(new Text("1"));
table[1, 1] = new TableCell(new Text("Laptop"));
table[1, 2] = new TableCell(new Text("$999"));

table[2, 0] = new TableCell(new Text("2"));
table[2, 1] = new TableCell(new Text("Smartphone"));
table[2, 2] = new TableCell(new Text("$499"));

table[3, 0] = new TableCell(new Text("3"));
table[3, 1] = new TableCell(new Text("Tablet"));
table[3, 2] = new TableCell(new Text("$299"));

table[4, 0] = new TableCell(new Text("4"));
table[4, 1] = new TableCell(new Text("Smartwatch"));
table[4, 2] = new TableCell(new Text("$199"));

// Add table
document.AddTable(table);

// Save the document
document.SaveAs("F:\\styled_document.docx");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbqx0udxb3929momirzk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbqx0udxb3929momirzk.png" alt="Image description" width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, we’ve explored how to programmatically create, manipulate, and edit docx files using the IronWORD library in C#. Starting with the installation of the IronWORD library, we walked through the process of loading existing documents and creating new ones. We demonstrated how to add and format text, insert images, and manipulate tables to enhance the document’s appearance and functionality. Finally, we covered how to save the edited documents, either by creating new files or keeping the same file.&lt;/p&gt;

&lt;p&gt;IronWORD offers a powerful and flexible solution for handling MS Word documents within .NET applications. It is an invaluable tool for developers looking to automate document workflows and ensure high-quality output. By integrating IronWORD into your projects, you can streamline the processing of different document formats, reduce manual effort, and maintain consistency across your documents. &lt;/p&gt;

&lt;p&gt;IronWORD also provides a &lt;a href="https://ironsoftware.com/csharp/word/licensing/"&gt;free trial&lt;/a&gt;, allowing you to explore its capabilities without any initial investment. Should you decide to use it in a production environment, licenses start at $749, offering a cost-effective solution for professional-grade document management.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>csharp</category>
    </item>
    <item>
      <title>3 Python PDF Libraries (Updated List For Developer)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Fri, 14 Jul 2023 03:48:44 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/3-python-pdf-libraries-updated-list-for-developer-a6d</link>
      <guid>https://dev.to/tayyabcodes/3-python-pdf-libraries-updated-list-for-developer-a6d</guid>
      <description>&lt;p&gt;In the vast world of Python libraries, there are some dedicated solely to working with Portable Document Format (PDF) files. These Python PDF libraries simplify the process of creating, modifying, and extracting text from PDF documents. This article presents three of the best Python PDF libraries that will take your Python PDF processing to the next level: IronPDF, PyPDF4, and PyMuPDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  IronPDF - A Powerful PDF Processing Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ironpdf.com/python/?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt; is a powerful and versatile Python library designed for creating, editing, and extracting content from PDF documents. It empowers developers to seamlessly integrate PDF functionalities into their Python projects, whether it's generating reports from HTML, filling out interactive forms, or securing sensitive documents. As of early 2025 (latest noted version 2025.4.1.4), IronPDF is actively maintained and has ongoing support and feature enhancements.&lt;/p&gt;

&lt;p&gt;A key advantage of IronPDF is its broad &lt;strong&gt;cross-platform compatibility&lt;/strong&gt;, supporting Python 3.7+ across Windows, macOS, Linux, Docker, Azure, and AWS environments. It's important to note that IronPDF for Python relies on the .NET 6.0 runtime; users on Linux and macOS may need to ensure this is installed on their systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Getting started with IronPDF is straightforward using pip:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install IronPdf&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features &amp;amp; Capabilities
&lt;/h3&gt;

&lt;p&gt;IronPDF boasts a comprehensive suite of features that caters to a wide array of PDF-related tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Advanced PDF Generation:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTML to PDF:&lt;/strong&gt; Accurately &lt;a href="//ttps://ironpdf.com/python/tutorials/html-to-pdf/?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary"&gt;convert HTML files to PDF&lt;/a&gt;, complex HTML strings (with CSS, JavaScript, and images), and live URLs into high-quality PDF documents. IronPDF is known for its &lt;strong&gt;pixel-perfect rendering&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image to PDF:&lt;/strong&gt; Convert various image formats into PDF documents.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Comprehensive PDF Editing &amp;amp; Manipulation:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Page Operations:&lt;/strong&gt; Easily merge multiple PDF documents or split a single PDF into several files.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Modification:&lt;/strong&gt; Add new content from HTML, insert text, apply watermarks, add annotations (like text highlights or comments), and create or edit bookmarks for easier navigation.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Headers and Footers:&lt;/strong&gt; Programmatically add consistent headers and footers across your PDF pages.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Form Handling:&lt;/strong&gt; Create new interactive PDF forms or programmatically fill existing ones. This includes accessing form fields by name and setting their values.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document Settings:&lt;/strong&gt; Manage document metadata (author, title, keywords), enforce security with password protection, set user permissions (e.g., restrict printing or editing), and apply digital signatures for document authenticity.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Flexible Formatting Options:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full HTML Asset Support:&lt;/strong&gt; Utilize existing HTML, CSS, JavaScript, and font resources directly in your PDF generation process.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customizable Views:&lt;/strong&gt; Control rendering aspects like responsive layouts and default zoom levels.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Templates:&lt;/strong&gt; Apply reusable templates for headers, footers, and page numbering.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page Customization:&lt;/strong&gt; Define paper size (e.g., A4, Letter), orientation (portrait, landscape), margins, and color settings.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Performance and Scalability:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;IronPDF is designed for efficiency, offering full multithreading and asynchronous (Async) support to handle demanding PDF processing tasks and enhance application performance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Convert a URL to PDF:
&lt;/h4&gt;

&lt;p&gt;This example demonstrates how to render a live webpage as a PDF and save it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from ironpdf import *

# Optional: Set your license key if you have one
# License.LicenseKey = "YOUR_LICENSE_KEY"

# Optional: Enable debugging and set logging options if needed
# Logger.EnableDebugging = True
# Logger.LogFilePath = "IronPdf.log"
# Logger.LoggingMode = Logger.LoggingModes.All

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Create a PDF from a URL
pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/python/")

# Save the PDF
pdf.SaveAs("IronPDF_Python_Page.pdf")

print("PDF created successfully from URL.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we first import the IronPDF library. Then we add the license key and set up the logger for debugging, optionally. We instantiate the ChromePdfRenderer, and then render a PDF from a URL. Finally, the output file is saved as 'IronPDF_Python_Page.pdf'.&lt;/p&gt;

&lt;p&gt;Here is the output file generated by IronPDF:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ni2kt893d60h3d3jrnh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ni2kt893d60h3d3jrnh.png" alt="Image description" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Filling an Existing PDF Form:
&lt;/h4&gt;

&lt;p&gt;This snippet shows how to load a PDF containing an interactive form, &lt;a href="https://ironpdf.com/python/how-to/python-fill-pdf-form/" rel="noopener noreferrer"&gt;fill a specific field&lt;/a&gt;, and save the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from ironpdf import *

# Load an existing PDF document with a form
try:
    pdf_document = PdfDocument.FromFile("original_form.pdf")

    # Access a specific form field by its name
    # You might need to know the field names in your PDF form
    field_name_to_fill = "customer_name" # Example field name
    form_field = pdf_document.Form.GetField(field_name_to_fill)

    if form_field is not None:
        # Set the value of the form field
        form_field.Value = "John Doe"
        print(f"Field '{field_name_to_fill}' populated.")
    else:
        print(f"Field '{field_name_to_fill}' not found in the PDF.")

    # Save the modified PDF
    pdf_document.SaveAs("filled_form.pdf")
    print("Filled form saved as filled_form.pdf")

except Exception as e:
    print(f"An error occurred: {e}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Pricing &amp;amp; Licensing&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;IronPDF operates on a commercial license-based model, offering various tiers to suit different project scopes and developer needs, with prices starting from $749 (as per earlier information, verify current pricing on their official website). A &lt;a href="https://ironpdf.com/python/licensing/#trial-license?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; is available, allowing developers to evaluate its full capabilities before committing to a purchase.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why Choose IronPDF?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;IronPDF stands out for several reasons, making it a compelling choice for Python developers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accuracy and Quality:&lt;/strong&gt; Its exceptional HTML-to-PDF rendering engine ensures that your PDFs look professional and exactly as intended.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comprehensive Feature Set:&lt;/strong&gt; From generation to intricate editing, form handling, and security, IronPDF covers a vast range of PDF functionalities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of Use:&lt;/strong&gt; Despite its power, IronPDF provides a user-friendly API that simplifies complex PDF operations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-Platform Flexibility:&lt;/strong&gt; Develop on your preferred OS and deploy across various environments without compatibility concerns.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developer Support:&lt;/strong&gt; IronPDF typically offers comprehensive documentation and technical support 24/7&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt; Built for efficiency with multithreading and async support, it can handle demanding PDF tasks effectively.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For developers seeking a robust, feature-rich, and well-supported Python library for all things PDF, IronPDF presents a strong and reliable solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  PyPDF4 - A Pure Python PDF Library for Manipulating PDFs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pypi.org/project/PyPDF4/" rel="noopener noreferrer"&gt;PyPDF4&lt;/a&gt; is a popular Python library that allows you to manipulate PDF files. It offers features like splitting PDFs, merging multiple pages, rotating PDF pages, and even handling password-protected files. This pure Python PDF library lets you write PDF files, extract document information, and much more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;

&lt;p&gt;You can install PyPDF4 using the pip command:&lt;br&gt;
&lt;code&gt;pip install pypdf4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The following code demonstrates how to retrieve text from a single page of a PDF document using PyPDF4.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from PyPDF4 import PdfFileReader
pdf = PdfFileReader("example.pdf")
first_page = pdf.getPage(0)
print(first_page.extract_text())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example code, we first import the PdfFileReader class from the PyPDF4 library. Next, we open a PDF file and retrieve the text from the first page of the document using the getPage function.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;PyPDF4 is a free and open-source Python library.&lt;/p&gt;

&lt;h2&gt;
  
  
  PyMuPDF - A Versatile Python PDF Library for Advanced Tasks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pymupdf.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;PyMuPDF&lt;/a&gt; is a really handy tool while working with PDFs in Python. It lets you do a bunch of cool things with PDFs like pulling out text, images, and background info (that's the 'metadata'). You can also use it to crop your PDFs or turn pages around. But the big standout is that PyMuPDF can handle messy data - the kind that doesn't fit into neat columns and rows - which is great if you're working on understanding or analyzing text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;

&lt;p&gt;You can install the PyMuPDF library using the pip command:&lt;br&gt;
&lt;code&gt;pip install pymupdf&lt;/code&gt;&lt;br&gt;
Here's an example demonstrating how to extract all text from a PDF file and save it as a .txt file using PyMuPDF:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sys, pathlib, fitz

# Get document filename
fname = sys.argv[1]  

# Open the document
with fitz.open(fname) as doc: 
    # Extract all text
    text = chr(12).join([page.get_text() for page in doc])

# Write the extracted text to a binary file (to support non-ASCII characters)
pathlib.Path(fname + ".txt").write_bytes(text.encode())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we open the PDF document using the filename passed as a command-line argument (sys.argv[1]). Then, we extract all the text from each page of the document and join them using form feed character (chr(12)). Finally, we write the text to a .txt file. The encoding to bytes is necessary to support non-ASCII characters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;PyMuPDF is a free and open-source Python library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, handling PDF files can be a crucial task. From creating and editing PDFs to extracting text and data, Python libraries dedicated to PDF processing have become essential tools.&lt;/p&gt;

&lt;p&gt;IronPDF, a highly efficient library, shines through with its robust functionality. From creating PDFs and converting HTML to PDF, to embedding custom data and smoothly converting webpages into PDFs, IronPDF packs a punch. Standalone by nature, IronPDF works independently, negating the need for additional dependencies or language packs. It also offers &lt;a href="https://ironpdf.com/python/examples/using-html-to-create-a-pdf/#trial-license?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; which is a big plus.&lt;/p&gt;

&lt;p&gt;PyPDF4, a purely Python library, allows for manipulation of PDFs in various ways, from splitting and merging multiple pages, to rotating pages and handling password-protected files. PyMuPDF, the third contender, doesn't just extract text and images, but also metadata from PDFs.&lt;/p&gt;

&lt;p&gt;While PyPDF4 and PyMuPDF are robust libraries in their own right, IronPDF stands out as a slightly superior choice for a few reasons. Its unique ability to seamlessly add custom data and efficiently convert webpages into PDFs is a game-changer. Furthermore, IronPDF's ability to work as a stand-alone solution without the need for additional dependencies, makes it an incredibly convenient option for developers. Its license-based pricing model also provides flexibility for different project scopes.&lt;/p&gt;

&lt;p&gt;So, if you're looking for a Python PDF library, IronPDF, PyPDF4, and PyMuPDF each bring something valuable to the table. IronPDF, however, has a slight edge with its unique features and independent nature. But best choice really depends on the task at hand.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>6 Java PDF Libraries: In-Depth Review for Developers</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Thu, 05 Jan 2023 07:33:56 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/heres-3-popular-java-pdf-libraries-fhf</link>
      <guid>https://dev.to/tayyabcodes/heres-3-popular-java-pdf-libraries-fhf</guid>
      <description>&lt;p&gt;As a Java or software developer, you'll know that PDFs are an important format to work with. But did you know that there are libraries specifically designed to help you work with PDFs? This article will introduce three popular PDF libraries and show you how to use them.&lt;/p&gt;

&lt;p&gt;If you're creating new PDF documents, these libraries will help make your job easier. Stay tuned for more Java programming tips and tricks!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;a href="https://ironpdf.com/java?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;IronPDF&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwcpt80yg6t08e0dw2s7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwcpt80yg6t08e0dw2s7c.png" alt="Image description" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ironpdf.com/java/" rel="noopener noreferrer"&gt;IronPDF for Java&lt;/a&gt; is a powerful and complete library built for developers who need to create, edit, and work with PDF documents directly within Java applications. It’s especially well known for its accurate HTML-to-PDF conversion, easy setup, and developer-friendly syntax. From generating PDFs from scratch to editing existing files, IronPDF makes the process straightforward.&lt;/p&gt;

&lt;p&gt;It supports a wide range of PDF features. You can fill out PDF forms, insert images, add bookmarks, and build tables of contents with ease. The library also includes features like password protection, encryption, and digital signatures, which are important when handling sensitive documents in business or legal settings.&lt;/p&gt;

&lt;p&gt;IronPDF works with Java 8 and above, making it suitable for both modern applications and legacy environments. It is distributed as a single JAR file and doesn't rely on any complex dependencies or external rendering engines. You can get it directly from the Sonatype Central Repository or explore more through the &lt;a href="https://ironpdf.com/java/docs/" rel="noopener noreferrer"&gt;official IronPDF Java documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Core Features of IronPDF for Java&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;IronPDF for Java offers a robust set of functionalities for comprehensive PDF management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. HTML to PDF Conversion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A primary strength of IronPDF is its highly accurate HTML to PDF conversion. It meticulously renders modern HTML5, CSS3, and JavaScript, essentially functioning like an up-to-date browser. This includes full support for web assets such as images, stylesheets, and scripts, ensuring your web content translates faithfully to PDF.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.ironsoftware.ironpdf.*;
PdfDocument myPdf = PdfDocument.renderUrlAsPdf("https://getbootstrap.com/");
myPdf.saveAs(Paths.get("url.pdf"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of the code above will display what it has created in the following image. IronPDF preserves the PDF quality and renders all images and buttons with great quality.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5s9opg4uk5hqiw4fqp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5s9opg4uk5hqiw4fqp8.png" alt="Image description" width="800" height="1882"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. PDF Editing and Manipulation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;IronPDF excels in modifying existing documents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fill and Read PDF Forms:&lt;/strong&gt; A standout feature is the ease of programmatically interacting with PDF forms. IronPDF allows you to define forms directly in HTML and then programmatically fill them, as shown below. This process, from creating forms from HTML to filling them, is detailed in resources like the &lt;a href="https://ironpdf.com/java/how-to/java-fill-pdf-form-tutorial/" rel="noopener noreferrer"&gt;IronPDF Java form tutorial&lt;/a&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Ensure IronPDF is in your classpath/dependencies
import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.render.ChromePdfRenderOptions;
import java.io.IOException;
import java.nio.file.*;

// #1 Use Case: Create a PDF Form from HTML Form Markup
// Note: Ensure the 'assets' directory exists at your project root or adjust the path.
Path outputLocation = Paths.get("assets/BasicForm.pdf");
String formHTML = "&amp;lt;html&amp;gt;"
    + "&amp;lt;body&amp;gt;"
    + "&amp;lt;h2&amp;gt;Editable PDF Form&amp;lt;/h2&amp;gt;"
    + "&amp;lt;form&amp;gt;"
    + "First name: &amp;lt;br&amp;gt; &amp;lt;input type='text' name='firstname' value=''&amp;gt; &amp;lt;br&amp;gt;"
    + "Last name: &amp;lt;br&amp;gt; &amp;lt;input type='text' name='lastname' value=''&amp;gt;"
    + "&amp;lt;/form&amp;gt;"
    + "&amp;lt;/body&amp;gt;"
    + "&amp;lt;/html&amp;gt;";

ChromePdfRenderOptions renderOptions = new ChromePdfRenderOptions();
renderOptions.setCreatePdfFormsFromHtml(true);
PdfDocument.renderHtmlAsPdf(formHTML, renderOptions).saveAs(outputLocation);

// #2 Use Case: Writing Values to the PDF Form
PdfDocument form = PdfDocument.fromFile(outputLocation);

// Set the value of the firstname input field.
form.getForm().setFieldValue("firstname", "Minnie");

// Set the value of the lastname input field.
form.getForm().setFieldValue("lastname", "Mouse");

// Save the changes to the PDF Form.
form.saveAs(Paths.get("assets/BasicForm_Filled.pdf"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding Content:&lt;/strong&gt; Easily add new text, images, and annotations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Merging and Splitting:&lt;/strong&gt; Combine multiple PDFs or divide a single document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stamping and Watermarking:&lt;/strong&gt; Apply stamps, watermarks, headers, and footers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt; Secure PDFs with passwords, permissions, and digital signatures (verify specific features on the IronPDF Java page).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. PDF Content Extraction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Efficiently extract valuable information: "Extract Text and Images: Accurately extract text content and images from PDF documents, preserving layout where possible." This allows you to repurpose or analyze content locked within PDFs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Cross-Platform Support&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Built for versatility, IronPDF "Works on Windows, Linux, macOS, and cloud environments where Java is supported." This ensures your PDF functionalities are deployable across diverse infrastructures.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Installation and Setup&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Getting IronPDF integrated into your Java project is straightforward, especially if you're using a modern build automation tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy Integration with Maven/Gradle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The recommended way to add IronPDF to your project is by using Maven or Gradle. This handles dependency management seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maven:&lt;/strong&gt; Add the following dependency to your project's &lt;code&gt;pom.xml&lt;/code&gt; file. Remember to replace &lt;code&gt;[LATEST_VERSION]&lt;/code&gt; with the most current version number available on &lt;a href="https://central.sonatype.com/artifact/com.ironsoftware/ironpdf" rel="noopener noreferrer"&gt;Sonatype Central&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;com.ironsoftware&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;ironpdf&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;[LATEST_VERSION]&amp;lt;/version&amp;gt; 
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Gradle:&lt;/strong&gt; For Gradle projects, add this line to your &lt;code&gt;build.gradle&lt;/code&gt; file's dependencies section. As with Maven, ensure you use the latest version by checking &lt;a href="https://central.sonatype.com/artifact/com.ironsoftware/ironpdf" rel="noopener noreferrer"&gt;Sonatype Central&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.ironsoftware:ironpdf:[LATEST_VERSION]' // Check Sonatype Central for the latest version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Direct JAR Download&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Maven or Gradle is preferred for managing dependencies, you can also download the IronPDF JAR file directly from the &lt;a href="https://ironpdf.com/java/" rel="noopener noreferrer"&gt;IronPDF website&lt;/a&gt; or potentially from Sonatype Central. However, using a build tool will make it easier to manage updates and transitive dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Licensing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk3j7rj3p95nrvo95676.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk3j7rj3p95nrvo95676.png" alt="Image description" width="800" height="489"&gt;&lt;/a&gt;&lt;br&gt;
IronPDF is a commercial library, offering a robust set of features for professional use. It provides a free trial that allows for full development and testing (often with a watermark). For production use or to remove trial limitations, a license key is required. The IronPDF java PDF library price starts from $749 for the lite plan and there are many to choose from depending on your needs. You can find more details about licensing options on the &lt;a href="https://ironpdf.com/java/licensing/?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;IronPDF licensing page&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Why Choose IronPDF for Your Java Projects?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When considering a PDF library for your Java application, several factors come into play. IronPDF stands out due to a combination of its user-centric design, robust performance, and extensive capabilities. Here are some key advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developer-Friendly API:&lt;/strong&gt; IronPDF is designed with ease of use in mind. Its intuitive API allows developers to integrate PDF functionalities quickly and efficiently, reducing the learning curve and speeding up development cycles. You can often achieve complex tasks with just a few lines of code.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accuracy and Reliability:&lt;/strong&gt; The library is engineered for high fidelity, especially in its core HTML to PDF rendering. It ensures that your documents are generated with precision. Furthermore, its PDF manipulation capabilities are robust, providing reliable performance for editing, form filling, and content extraction.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comprehensive Feature Set:&lt;/strong&gt; IronPDF isn't limited to a single function. It offers a wide range of features covering the entire PDF lifecycle – from initial creation and conversion (e.g., HTML to PDF) through advanced editing, interactive form filling, data extraction, and document security. This makes it a versatile tool for diverse PDF requirements.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Good Documentation and Support:&lt;/strong&gt; Successful integration often relies on strong support resources. IronPDF is backed by detailed documentation, practical tutorials (like the Java PDF form filling guide mentioned earlier), and access to support from Iron Software, helping developers resolve issues and make the most of the library's features.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2. iText7 Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F123amql2az7f91209gx4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F123amql2az7f91209gx4.png" alt="Image description" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;iText7 is a PDF library designed specifically to create high-quality PDF documents from scratch. It allows you to create both simple and complex documents in a variety of file formats, including HTML5.&lt;/p&gt;

&lt;p&gt;iText7 includes features like digital signatures and encryption so that users can securely share their documents with others over the internet.&lt;/p&gt;

&lt;p&gt;With its wide array of features and easy deployment options, iText has become one of the go-to libraries for Java developers when working with PDF formats.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create PDF files - Code Example
&lt;/h2&gt;

&lt;p&gt;Using the following code, you can create a simple table in PDFs using the iText library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.itextpdf.samples.sandbox.tables;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.properties.UnitValue;

import java.io.File;

public class SimpleTable {
    public static final String DEST = "./target/sandbox/tables/simple_table.pdf";

    public static void main(String[] args) throws Exception {
        File file = new File(DEST);
        file.getParentFile().mkdirs();

        new SimpleTable().manipulatePdf(DEST);
    }

    protected void manipulatePdf(String dest) throws Exception {
        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
        Document doc = new Document(pdfDoc);

        Table table = new Table(UnitValue.createPercentArray(8)).useAllAvailableWidth();

        for (int i = 0; i &amp;lt; 16; i++) {
            table.addCell("hi");
        }

        doc.add(table);

        doc.close();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code contains a class that will create a table comprised of 16 cells.&lt;/p&gt;

&lt;p&gt;This is the resulting output in the following image.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forl48gm426e8xt5inc1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forl48gm426e8xt5inc1u.png" alt="Image description" width="667" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can add a digital signature using the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.itextpdf.samples.signatures.chapter02;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.StampingProperties;
import com.itextpdf.signatures.PdfSigner;
import com.itextpdf.signatures.PdfSignatureAppearance;
import com.itextpdf.signatures.IExternalSignature;
import com.itextpdf.signatures.IExternalDigest;
import com.itextpdf.signatures.PrivateKeySignature;
import com.itextpdf.signatures.BouncyCastleDigest;
import com.itextpdf.signatures.DigestAlgorithms;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Security;
import java.security.cert.Certificate;

public class C2_02_SignHelloWorldWithTempFile {
    public static final String DEST = "./target/signatures/chapter02/";

    public static final String KEYSTORE = "./src/test/resources/encryption/ks";
    public static final String SRC = "./src/test/resources/pdfs/hello.pdf";

    public static final char[] PASSWORD = "password".toCharArray();

    public static final String[] RESULT_FILES = new String[] {
            "hello_signed_with_temp.pdf"
    };

    public void sign(String src, String temp, String dest, Certificate[] chain, PrivateKey pk,
            String digestAlgorithm, String provider, PdfSigner.CryptoStandard subfilter,
            String reason, String location)
            throws GeneralSecurityException, IOException {
        PdfReader reader = new PdfReader(src);

        // Pass the temporary file's path to the PdfSigner constructor
        PdfSigner signer = new PdfSigner(reader, new FileOutputStream(dest), temp, new StampingProperties());

        // Create the signature appearance
        Rectangle rect = new Rectangle(36, 648, 200, 100);
        PdfSignatureAppearance appearance = signer.getSignatureAppearance();
        appearance
                .setReason(reason)
                .setLocation(location)

                // Specify if the appearance before field is signed will be used
                // as a background for the signed field. The "false" value is the default value.
                .setReuseAppearance(false)
                .setPageRect(rect)
                .setPageNumber(1);
        signer.setFieldName("sig");

        IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, provider);
        IExternalDigest digest = new BouncyCastleDigest();

        // Sign the document using the detached mode, CMS or CAdES equivalent.
        signer.signDetached(digest, pks, chain, null, null, null, 0, subfilter);
    }

    public static void main(String[] args) throws GeneralSecurityException, IOException {
        File file = new File(DEST);
        file.mkdirs();

        BouncyCastleProvider provider = new BouncyCastleProvider();
        Security.addProvider(provider);
        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        ks.load(new FileInputStream(KEYSTORE), PASSWORD);
        String alias = ks.aliases().nextElement();
        PrivateKey pk = (PrivateKey) ks.getKey(alias, PASSWORD);
        Certificate[] chain = ks.getCertificateChain(alias);

        new C2_02_SignHelloWorldWithTempFile().sign(SRC, DEST, DEST + RESULT_FILES[0], chain, pk,
                DigestAlgorithms.SHA256, provider.getName(), PdfSigner.CryptoStandard.CMS,
                "Temp test", "Ghent");
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will add a digital signature, using the latest version of iText7.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pricing
&lt;/h2&gt;

&lt;p&gt;There is no pricing plan mentioned on the website. You must get a quote from customer support for purchasing the license. However, you can get some resources for free like iText 7 Core and pdfHTML. Find more information about iText7 licensing using the following &lt;a href="https://itextpdf.com/get-your-itext-license" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ufs3bisamvt4k3nm2in.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ufs3bisamvt4k3nm2in.png" alt="Image description" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. jPDFProcess
&lt;/h2&gt;

&lt;p&gt;jPDFProcess is a Java library designed specifically to create high-quality PDFs, documents or images from scratch. With this tool you can quickly generate complex documents such as invoices or catalogs with ease thanks to its intuitive API and rich feature set including support for text manipulation, form creation/filling/submission, and more.&lt;/p&gt;

&lt;p&gt;Additionally, jPDFProcess also provides an API for digitally signing documents using digital certificates. This makes it ideal for certain document exploitation scenarios like eSignatures or document archiving processes involving digital signatures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Example
&lt;/h2&gt;

&lt;p&gt;You can use the following code to create PDF files using the jPDFProcess open-source java tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
 * This sample java program uses jPDFProcess
 * to create a new PDF file, add a page to it
 * and draw an image and text on the page.
 * 
 */
package jPDFProcessSamples;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import com.qoppa.pdfProcess.PDFDocument;
import com.qoppa.pdfProcess.PDFGraphics;
import com.qoppa.pdfProcess.PDFPage;

public class CreatePDFWithTextAndImage
{
    public static void main (String [] args)
    {
        try
        {
            // create document
            PDFDocument pdfDoc = new PDFDocument ();

            // create and add a page
            PDFPage page = pdfDoc.appendNewPage(8.5 * 72, 11 * 72);

            // get graphics from the page
            // this object is a Graphics2D Object and you can draw anything 
            // you would draw on a Graphics2D
            PDFGraphics g2d = (PDFGraphics) page.createGraphics();

            // read an image from png,. jpeg, etc... 
            BufferedImage image = ImageIO.read(new File("C:\\myimage.png"));

            // draw the image on the page
            g2d.drawImage(image, 0, 0, null);

            // set the font and color
            g2d.setFont (PDFGraphics.HELVETICA.deriveFont(24f));
            g2d.setColor(Color.BLUE);

            // draw text on the graphics object of the page
            g2d.drawString("NEW TEXT", 200, 100);

            // Save the document
            pdfDoc.saveDocument ("C:\\test.pdf");
        }
        catch(Throwable t)
        {
            t.printStackTrace();
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above will create a PDF document, add a page on it and draw an image and text on that page.&lt;/p&gt;

&lt;p&gt;We can add a watermark to the PDF file using the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package jPDFProcessSamples;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import com.qoppa.pdfProcess.PDFDocument;
import com.qoppa.pdfProcess.PDFGraphics;
import com.qoppa.pdfProcess.PDFPage;

public class AddWatermark
{
    public static void main (String [] args)
    {
        try
        {
            // Load document
            PDFDocument pdfDoc = new PDFDocument ("input.pdf", null);

            // Loop through all pages
            Font wmFont = PDFGraphics.HELVETICA.deriveFont(64f);
            for (int pageIx = 0; pageIx &amp;lt; pdfDoc.getPageCount(); ++pageIx)
            {
                // Get the page
                PDFPage page = pdfDoc.getPage(pageIx);

                // Get a graphics object to draw onto the page
                Graphics2D g2d = page.createGraphics();

                // Draw watermark
                g2d.setColor (new Color (160, 160, 160, 160));
                g2d.setFont(wmFont);
                g2d.translate(72, 72 + g2d.getFontMetrics().getAscent());
                g2d.rotate(Math.toRadians(45));
                g2d.drawString ("Confidential", 0, 0);
            }

            // Save the document
            pdfDoc.saveDocument ("output.pdf");
        }
        catch (Throwable t)
        {
            t.printStackTrace();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above contains a class with a method that will loop through all the pages and a draw watermark on each one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;jPDFProcess is an open-source java library. We can use its PDF features for free.&lt;/p&gt;

&lt;h2&gt;
  
  
  4- Apache PDFBox
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pdfbox.apache.org/" rel="noopener noreferrer"&gt;Apache PDFBox&lt;/a&gt; is an open-source Java library that enables developers to work with PDF documents efficiently. With PDFBox, you can create new PDFs, manipulate existing ones, and extract content such as text and metadata.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features of Apache PDFBox
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extract Text:&lt;/strong&gt; Retrieve Unicode text from PDF files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split &amp;amp; Merge:&lt;/strong&gt; Divide a single PDF into multiple files or combine several PDFs into one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fill Forms:&lt;/strong&gt; Extract data from PDF forms or populate them programmatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Preflight:&lt;/strong&gt; Validate PDFs against the PDF/A-1b standard to ensure compliance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Print:&lt;/strong&gt; Utilize the standard Java printing API to print PDF documents.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;

&lt;p&gt;Here's a simple example demonstrating how to create a PDF with text using Apache PDFBox:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

import java.io.IOException;

public class CreatePDF {
    public static void main(String[] args) {
        try (PDDocument document = new PDDocument()) {
            PDPage page = new PDPage();
            document.addPage(page);

            try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) {
                contentStream.beginText();
                contentStream.setFont(PDType1Font.TIMES_ROMAN, 12);
                contentStream.newLineAtOffset(100, 700);
                contentStream.showText("Hello, PDFBox!");
                contentStream.endText();
            }

            document.save("HelloPDFBox.pdf");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a PDF named HelloPDFBox.pdf with the text "Hello, PDFBox!" positioned at coordinates (100, 700) on the page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;Apache PDFBox is released under the Apache License 2.0, making it free for both personal and commercial use. For more detailed information and tutorials, refer to the official documentation of Apache PDFBox.&lt;/p&gt;

&lt;h2&gt;
  
  
  5- Aspose.PDF for Java
&lt;/h2&gt;

&lt;p&gt;​&lt;a href="https://products.aspose.com/pdf/java/" rel="noopener noreferrer"&gt;Aspose.PDF for Java&lt;/a&gt; is a robust library that empowers developers to create, manipulate, and transform PDF documents within Java applications without relying on Adobe Acrobat. It offers a comprehensive suite of features, including the ability to add text, images, tables, and graphs to PDFs, as well as functionalities for merging, splitting, and encrypting documents. This flexibility makes it a valuable tool for applications requiring dynamic PDF generation and management.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;

&lt;p&gt;To illustrate its capabilities, here's a simple example demonstrating how to extract text from a PDF using Aspose.PDF for Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.aspose.pdf.Document;
import com.aspose.pdf.TextAbsorber;

public class ExtractText {
    public static void main(String[] args) {
        // Open the PDF document
        Document pdfDocument = new Document("input.pdf");

        // Create a TextAbsorber object to extract text
        TextAbsorber textAbsorber = new TextAbsorber();

        // Accept the absorber for all the pages
        pdfDocument.getPages().accept(textAbsorber);

        // Get the extracted text
        String extractedText = textAbsorber.getText();

        // Display the text
        System.out.println(extractedText);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this snippet, we open an existing PDF file, utilize the TextAbsorber class to extract its text content, and then print the extracted text to the console. This example showcases the straightforward API design of Aspose.PDF for Java, enabling developers to perform complex PDF operations with minimal code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;Aspose.PDF for Java offers several licensing options to accommodate different organizational needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Developer Small Business License:&lt;/strong&gt; Priced at $1,199, this license permits one developer and one deployment location, including free support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer OEM License:&lt;/strong&gt; At $3,597, this license allows one developer and unlimited deployment locations, also with free support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Site Small Business License:&lt;/strong&gt; For $5,995, this license covers up to 10 developers and 10 deployment locations, with free support included.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additional licensing options are available, such as Metered and Site OEM licenses, each tailored to specific business requirements. For a detailed breakdown of these options and to explore paid support and consulting services, you can visit the &lt;a href="https://purchase.aspose.com/pricing/pdf/java/" rel="noopener noreferrer"&gt;official pricing page&lt;/a&gt;. ​&lt;/p&gt;

&lt;h2&gt;
  
  
  6- PDF Clown
&lt;/h2&gt;

&lt;p&gt;​&lt;a href="https://pdfclown.org/" rel="noopener noreferrer"&gt;PDF Clown&lt;/a&gt; is an open-source library designed for Java and .NET platforms, enabling developers to create, manipulate, and extract data from PDF documents. Adhering strictly to the PDF 1.7 specification (ISO 32000-1), it offers a versatile toolset for handling various PDF operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;

&lt;p&gt;To illustrate its capabilities, here's a simple example demonstrating how to extract text from a PDF using PDF Clown in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.pdfclown.files.File;
import org.pdfclown.documents.Document;
import org.pdfclown.documents.Page;
import org.pdfclown.tools.TextExtractor;

public class ExtractText {
    public static void main(String[] args) {
        // Open the PDF document
        File file = new File("input.pdf");
        Document document = file.getDocument();

        // Instantiate a TextExtractor
        TextExtractor textExtractor = new TextExtractor();

        // Iterate through the pages
        for (Page page : document.getPages()) {
            // Extract text from the page
            String text = textExtractor.extract(page);
            // Display the text
            System.out.println(text);
        }

        // Close the file
        file.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this snippet, we open an existing PDF file, use the TextExtractor class to extract text from each page, and then print the extracted text to the console. This example showcases the straightforward API design of PDF Clown, enabling developers to perform complex PDF operations with minimal code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing
&lt;/h3&gt;

&lt;p&gt;PDF Clown is released under the GNU Lesser General Public License (LGPL), making it free for both personal and commercial use. This open-source model allows developers to integrate PDF Clown into their projects without licensing fees, providing a cost-effective solution for PDF manipulation needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature / Library&lt;/th&gt;
&lt;th&gt;IronPDF ⭐️&lt;/th&gt;
&lt;th&gt;iText7&lt;/th&gt;
&lt;th&gt;jPDFProcess&lt;/th&gt;
&lt;th&gt;Apache PDFBox&lt;/th&gt;
&lt;th&gt;Aspose.PDF&lt;/th&gt;
&lt;th&gt;PDF Clown&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Create PDFs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (from HTML, URL, Images)&lt;/td&gt;
&lt;td&gt;✅ (Basic creation)&lt;/td&gt;
&lt;td&gt;✅ (Image/Text-based)&lt;/td&gt;
&lt;td&gt;✅ (Basic creation)&lt;/td&gt;
&lt;td&gt;✅ (Rich features)&lt;/td&gt;
&lt;td&gt;✅ (Basic creation)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modify PDFs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (Rich editing capabilities)&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Extract Text&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fill Forms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (Advanced form creation/editing)&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (Basic features)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTML to PDF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (Advanced support)&lt;/td&gt;
&lt;td&gt;✅ (Requires add-on)&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Digital Signatures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (Advanced)&lt;/td&gt;
&lt;td&gt;✅ (Advanced)&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Annotations&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Split/Merge PDFs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Encryption&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (Advanced security features)&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (Basic features)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pricing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Starts at $749&lt;/td&gt;
&lt;td&gt;Quote-based&lt;/td&gt;
&lt;td&gt;Free (Open-source)&lt;/td&gt;
&lt;td&gt;Free (Open-source)&lt;/td&gt;
&lt;td&gt;Starts at $1199&lt;/td&gt;
&lt;td&gt;Free (Open-source)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Free Trial&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ (30 days, no watermark)&lt;/td&gt;
&lt;td&gt;✅ (limited)&lt;/td&gt;
&lt;td&gt;✅ (open-source)&lt;/td&gt;
&lt;td&gt;✅ (open-source)&lt;/td&gt;
&lt;td&gt;✅ (limited)&lt;/td&gt;
&lt;td&gt;✅ (open-source)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Quality &amp;amp; Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️⭐️⭐️ (Excellent support)&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️⭐️&lt;/td&gt;
&lt;td&gt;⭐️⭐️⭐️&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;IronPDF is our preferred library of choice, as it offers slightly more features than IText7 and other libraries at a lower cost. We also found IronPDF to be beginner friendly, so a solid choice if you're a junior developer looking for a library to start with.&lt;/p&gt;

&lt;p&gt;iText7 does deliver good render outputs and processing speeds. It also has a freemium which you can use in your projects with limited capabilities. However, iText7 does not offer a free trial. It has good documentation but lacks tutorials for beginners. There is no fixed price mentioned on the website for the license. You have to contact support to get a quote.&lt;/p&gt;

&lt;p&gt;Aspose.PDF for Java provides comprehensive capabilities suitable for dynamic PDF generation but may pose a steeper learning curve. Pricing starts at $1,199. Apache PDFBox is a reliable, open-source option suitable for basic PDF tasks but lacks advanced commercial features.&lt;/p&gt;

&lt;p&gt;PDF Clown for Java is free and adheres strictly to PDF standards, ideal for straightforward PDF manipulations. jPDFProcess is also a good library but lacks many features. Regardless, it is a free library that has useful functionality.&lt;/p&gt;

&lt;p&gt;IronPDF has good documentation and tutorials to help you understand the process with almost no code. The license of IronPDF is optimized for all levels of users and starts at $749. IronPDF offers a &lt;a href="https://ironpdf.com/java/how-to/java-create-pdf-tutorial/#trial-license?utm_source=devto&amp;amp;utm_medium=tay&amp;amp;utm_campaign=pdflibrary" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; to let you test it in production.&lt;/p&gt;

&lt;p&gt;In conclusion, all six libraries are high-quality and will help developers get the job done.&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Five Killer Twitter Tips for Crypto Projects</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Thu, 26 May 2022 07:52:47 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/five-killer-twitter-tips-for-crypto-projects-36dn</link>
      <guid>https://dev.to/tayyabcodes/five-killer-twitter-tips-for-crypto-projects-36dn</guid>
      <description>&lt;p&gt;There’s a good reason the Dogefather aka Elon Musk wants Twitter — those who can react fastest will fare better than the rest. As Musk said in a recent interview, Twitter has become the town square and if you have a crypto project in the wings, now is the best time to find the best position in the plaza.&lt;/p&gt;

&lt;p&gt;So, without further ado here are five tips to tweak your Twitter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search and be found
&lt;/h2&gt;

&lt;p&gt;Twitter is arguably the most powerful social media network on earth, even though it does not rank in the global top ten in terms of users: a recent Statista study put Twitter rather surprisingly at 14th, while Wikipedia has it at 17th). But how? It’s the site’s unique search options that make the site so attractive to project managers.&lt;/p&gt;

&lt;p&gt;These advanced data options, alongside a plethora of third-party apps, allow Twitter users to hone in on and target almost any demographic. Twitter’s advanced search function also allows users to search for every conceivable term, so even if you can only remember a few words of a tweet you’re looking for, Twitter will help you find it.&lt;/p&gt;

&lt;p&gt;Whilst there’s no denying Twitter’s search functions are awesome, even the best of us have flaws but thanks to Twitter’s massive fan base, there’s a good chance someone else found and fixed it first. One great example is the Search Twitter Bookmark’s Chrome extension. The upgrade adds an additional search feature to Twitter’s own bookmark section, something Twitter itself does not allow.&lt;/p&gt;

&lt;h2&gt;
  
  
  One-click tricks
&lt;/h2&gt;

&lt;p&gt;The Twitter biome has long outgrown the nest and the site’s success has spawned vast numbers of third-party apps, services, sites, influencers, and experts. One of the most useful of these strands is the availability of ‘lists’.&lt;/p&gt;

&lt;p&gt;Helpful folks from all over the world have created specially curated profile lists in almost every conceivable sector you can imagine. As you’d expect, there are plenty of crypto lists, and following these lists with the right app or extension takes a single click.&lt;/p&gt;

&lt;p&gt;Historically, it would take journalists years to develop databases like these, which gives us a little window into just how powerful Twitter is. There are many ways to use lists inside and outside the Twitter app, or you can use a browser extension like this one to follow all of another account's followers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Broadcast from Spaces
&lt;/h2&gt;

&lt;p&gt;Sure, Twitter’s great for sharing the hottest memes or even just retweeting a cool tweet, but the site can also be used to share and even host other media. Twitter’s Spaces feature allows anyone to host a live audio chat and invite up to 12 other people to join in the discussion. These Spaces are aired live, and anyone can listen to them. This is a great way to hold an AMA (Ask Me Anything) session, or you even just use it to start a podcast. Spaces can be recorded by the host and shared again later, and listeners have the option to grab a 30-second clip to share themselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Industrious espionage
&lt;/h2&gt;

&lt;p&gt;Where Twitter really excels is when it comes to analysis. Using Twitter's advanced search features and some off-site apps and sites, users can take deep dives into any sector, competitor, or potential partner. With Twitter, it’s not only easy to see how many followers a competitor has, but you can also physically see where they are, what content their followers prefer, and the best time zones for peak Tweet engagement. There’s even a browser extension that can find key information on every Twitter account linked to a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Picture perfect
&lt;/h2&gt;

&lt;p&gt;Not every strategy requires an angle, or indeed a browser extension. Some, like jazzing up your profile, simply require a little common sense. Good profiles often have a single portrait picture,, a snappy tagline, and a short, but comprehensive biography that includes a couple of relevant #hashtags.  Hashtags are the secret sauce that drives Twitter, and you’ll want to make sure the tags you use are appropriate to your profile because Twitter uses these tags to categorize your account.&lt;/p&gt;

&lt;h2&gt;
  
  
  In summary
&lt;/h2&gt;

&lt;p&gt;There you have it, five easy Twitter hacks to nudge your numbers. These are, of course, only my personal suggestions and there are many other ways to amplify your message in the world’s town square. Feel free to add your own Twitter strategies in the comments and don’t forget to follow me on Twitter.&lt;br&gt;
&lt;a href="https://hackernoon.com/five-killer-twitter-tips-for-crypto-projects"&gt;Author&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Html to Pdf C# Converter (Code Example Tutorial)</title>
      <dc:creator>Tayyab Ali</dc:creator>
      <pubDate>Wed, 20 Apr 2022 06:57:31 +0000</pubDate>
      <link>https://dev.to/tayyabcodes/html-to-pdf-c-converter-code-example-tutorial-36p8</link>
      <guid>https://dev.to/tayyabcodes/html-to-pdf-c-converter-code-example-tutorial-36p8</guid>
      <description>&lt;p&gt;A pdf file is an electronic document that can be downloaded and stored on the computer. In this process, all the textual content from the website is converted into an image which is then formatted according to printing guidelines in Adobe Acrobat Pro DC or earlier versions. HTML to PDF Conversion is a document conversion process. It can convert HTML data into a PDF file or capture the content of an HTML page as an image. The web browser renders HTML as text on display, but it doesn't know how to do anything with it. The browser needs some assistance from another software that knows how to interpret and store the data in a format that you can view later, such as a popular one like PDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  IronPDF: C# PDF Library
&lt;/h2&gt;

&lt;p&gt;IronPDF is a .NET pdf library that can create PDF files on the fly without restoring them to other 3rd party software (i.e. Adobe Acrobat). It is compatible with all types of applications and web apps, and it provides a simple API for developers, enabling them to integrate PDF functionality into their applications. It can be used for HTML to pdf converter.&lt;/p&gt;

&lt;p&gt;IronPDF allows you to create, edit, convert and manage PDF documents. A developer can quickly create a PDF document with IronPDF by calling the set of functions for generating the content of the document, editing the text on different pages, and then converting it into a single PDF format without having to install expensive software such as Adobe Acrobat Pro or other PDF tools.&lt;/p&gt;

&lt;p&gt;This article will see how to convert HTML string to PDF files using IronPDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create C# Project
&lt;/h2&gt;

&lt;p&gt;To get started with IronPDF, we have to create a C# Project. I am using Visual Studio 2019 for this tutorial. You can choose any version that suits you, but the latest version is recommended. Follow the following steps to create a C# project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Visual Studio 2019.&lt;/li&gt;
&lt;li&gt;Click on the "Create New Project" button.&lt;/li&gt;
&lt;li&gt;Select "Console Application" from the templates.&lt;/li&gt;
&lt;li&gt;Give the project a name and click on the "Next" button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Select the .NET core framework according to your project requirement. The latest version of the .NET framework is recommended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install the IronPDF Library
&lt;/h2&gt;

&lt;p&gt;Now, it's time to install the IronPDF library in our created project. We can install the IronPDF library using multiple ways. Let's get explored it one by one:&lt;/p&gt;

&lt;h2&gt;
  
  
  1: NuGet Package Manager Console
&lt;/h2&gt;

&lt;p&gt;IronPDF is a NuGet Package. So, we can install the IronPDF library using the package manager console. Installation of IronPDF is very easy by using the console. We have to open the console, which mostly lies at the bottom of the project. After that, we will write the following command to install the IronPDF library in the console.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Install-Package IronPDF&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will start the installation. You will see the progress in the console. After installation, our project will be ready to use in the IronPDF library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kpp5cGp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yg8f9cuq7tv8vu7lt2tb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kpp5cGp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yg8f9cuq7tv8vu7lt2tb.png" alt="Image description" width="880" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2: NuGet Package Manager
&lt;/h2&gt;

&lt;p&gt;We can install the IronPDF library by using a GUI interface of NuGet Package Manager. Open the NuGet Package Manager by clicking on the following menus Tools &amp;gt; NuGet Package Manager &amp;gt; Manage NuGet Package Solution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aD24gk-s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p53x55xbdfx1biq960f9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aD24gk-s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p53x55xbdfx1biq960f9.png" alt="Image description" width="805" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to the Browse tab and search for IronPDF in the search bar. Select the IronPDF from the search results and click on the install button. It will begin the installation of the IronPDF library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kp5wrziE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2x3vy65wzxeksb3ueqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kp5wrziE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2x3vy65wzxeksb3ueqv.png" alt="Image description" width="880" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3: Using a DLL file
&lt;/h2&gt;

&lt;p&gt;If you don't want to use package manager then you can directly import the DLL file of IronPDF into your project. You can download the DLL file from this &lt;a href="https://ironpdf.com/packages/IronPdf.zip"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Download the DLL zip file. Extract it to a specific folder.&lt;/p&gt;

&lt;p&gt;In the Solution Explorer, right-click on References and browse for the IronPDF DLL file.&lt;/p&gt;

&lt;p&gt;For a more detailed installation guide, visit this &lt;a href="https://ironpdf.com/docs/questions/installation/"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add the IronPDF Namespace
&lt;/h2&gt;

&lt;p&gt;Now, we have to add the IronPDF namespace in our program file to use the IronPDF library. Write the following line of code on the top of every program file where you want to use the IronPDF library.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;using IronPDF;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing Code to Convert HTML to PDF
&lt;/h2&gt;

&lt;p&gt;IronPDF offers multiple ways to convert HTML to PDF conversion.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Converting HTML document to PDF file&lt;/li&gt;
&lt;li&gt;Converting HTML web page to PDF document&lt;/li&gt;
&lt;li&gt;Converting HTML strings to PDF file&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Convert HTML Document to PDF file
&lt;/h2&gt;

&lt;p&gt;Now it's time to write the code to convert the HTML file to pdf file format. We can create a seprate function or we can write the follwoing code to the main function.&lt;/p&gt;

&lt;p&gt;`var Renderer = new IronPdf.ChromePdfRenderer();&lt;br&gt;
using var PDF = Renderer.RenderHTMLFileAsPdf("Invoice.html");&lt;/p&gt;

&lt;p&gt;// HTML assets such as images, CSS, and JS will be automatically loaded. &lt;/p&gt;

&lt;p&gt;PDF.SaveAs("Invoice.pdf"); `&lt;/p&gt;

&lt;p&gt;The following given code takes the file path of HTML files as the parameter. We use RenderHTMLFileAsPdf function to perform conversion of HTML file to PDF document. It can be an HTML template or any other HTML file which you want to convert to a PDF file. At last, we save our PDF file using the SaveAs function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H3cOedDY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4c6r4dopox740jqmrzjo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H3cOedDY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4c6r4dopox740jqmrzjo.png" alt="Image description" width="698" height="810"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML Web Page to PDF document
&lt;/h2&gt;

&lt;p&gt;We can convert any HTML web page which is on the internet to a PDF document programmatically in our program. We will just need the URL of the web page to start conversion. See the following code example to convert HTML URL to PDF file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();&lt;br&gt;
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");&lt;br&gt;
Pdf.SaveAs("url.pdf");&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;The given code converts the URL to a PDF document. We use the RenderURLAsPdf function and give the URL as a parameter to the function. It automatically loads every formatting and converts the output to a PDF file. After that, we save the file using the SaveAs function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ilXFCY18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbpvlbuefk2mcg5bwvq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ilXFCY18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbpvlbuefk2mcg5bwvq1.png" alt="Image description" width="687" height="827"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting HTML strings to PDF file
&lt;/h2&gt;

&lt;p&gt;Third way to convert HTML to PDF is to create PDF file from scratch using HTML code. Let's see how we can do it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var ChromePdfRenderer = new ChromePdfRenderer();  &lt;br&gt;
// html to turn into pdf&lt;br&gt;
var html = @"&amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;&amp;lt;br&amp;gt;&amp;lt;p&amp;gt;This is IronPdf.&amp;lt;/p&amp;gt;";  &lt;br&gt;
// turn html to pdf&lt;br&gt;
using var pdf = ChromePdfRenderer.RenderHtmlAsPdf(html);&lt;br&gt;
// save resulting pdf into file&lt;br&gt;
pdf.SaveAs("ChromePdfRenderer.Pdf");&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the given code, we make an HTML string first and then we pass it to the RenderHtmlAsPdf function. It converts the HTML string to a PDF document. After that, we save the output file using the SaveAs function. We can add headers and footers to our PDF document by using HTML strings too. Multiple customizations are offered by IronPDF. You can get more details about &lt;a href="https://ironpdf.com/tutorials/html-to-pdf/"&gt;HTML to pdf converter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4o5G1W8o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o7e11y0i9r8rikdipwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4o5G1W8o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o7e11y0i9r8rikdipwd.png" alt="Image description" width="611" height="766"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Licensing:
&lt;/h2&gt;

&lt;p&gt;IronPDF is absolutely free for the developers. You can use IronPDF for development purposes with a watermark for free. But there is a price for the production level. You can avail the 30 days free trial key without any payment. After you make up your mind to purchase the IronPDF, there is an awesome offer waiting for you. Iron Software is a huge company that offers five products IronPDF, IronXL, IronOCR, IronBARCODE, and IronWebScraper. You can buy all five software for the price of just two pieces of software. It is an amazing offer. You must avail this opportunity. Get more details from this &lt;a href="https://ironsoftware.com/suite/"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can download the software product from this &lt;a href="https://ironpdf.com/downloads/html-to-pdf-devto.zip"&gt;link&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
