Convert Figma logo to code with AI

itext logoitext-dotnet

iText for .NET is the .NET version of the iText library, formerly known as iTextSharp, which it replaces. iText represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enha

1,797
332
1,797
15

Top Related Projects

iText for .NET is the .NET version of the iText library, formerly known as iTextSharp, which it replaces. iText represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enha

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)

Quick Overview

iText for .NET is a powerful PDF library that allows developers to create, manipulate, and process PDF documents programmatically. It provides a wide range of features for working with PDFs, including document generation, form filling, digital signatures, and more.

Pros

  • Comprehensive PDF manipulation capabilities
  • Cross-platform compatibility (Windows, macOS, Linux)
  • Active development and regular updates
  • Extensive documentation and community support

Cons

  • Commercial licensing required for many use cases
  • Steep learning curve for advanced features
  • Large library size may impact application performance
  • Some features require additional dependencies

Code Examples

  1. Creating a simple PDF document:
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

using (PdfWriter writer = new PdfWriter("output.pdf"))
using (PdfDocument pdf = new PdfDocument(writer))
using (Document document = new Document(pdf))
{
    document.Add(new Paragraph("Hello, iText!"));
}
  1. Adding a table to a PDF:
using iText.Layout.Element;

Table table = new Table(3);
table.AddCell("Column 1");
table.AddCell("Column 2");
table.AddCell("Column 3");
table.AddCell("Row 1, Cell 1");
table.AddCell("Row 1, Cell 2");
table.AddCell("Row 1, Cell 3");

document.Add(table);
  1. Adding an image to a PDF:
using iText.IO.Image;
using iText.Layout.Element;

Image img = new Image(ImageDataFactory.Create("path/to/image.jpg"));
document.Add(img);

Getting Started

  1. Install the iText 7 NuGet package:

    Install-Package itext7
    
  2. Add the following using statements to your C# file:

    using iText.Kernel.Pdf;
    using iText.Layout;
    using iText.Layout.Element;
    
  3. Create a simple PDF:

    using (PdfWriter writer = new PdfWriter("output.pdf"))
    using (PdfDocument pdf = new PdfDocument(writer))
    using (Document document = new Document(pdf))
    {
        document.Add(new Paragraph("My first PDF with iText!"));
    }
    

This will create a basic PDF file named "output.pdf" in your project directory with the text "My first PDF with iText!".

Competitor Comparisons

iText for .NET is the .NET version of the iText library, formerly known as iTextSharp, which it replaces. iText represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enha

Pros of itext-dotnet

  • More comprehensive documentation and examples
  • Wider range of PDF manipulation features
  • Active community support and regular updates

Cons of itext-dotnet

  • Larger codebase, potentially more complex to navigate
  • May have a steeper learning curve for beginners
  • Potentially higher resource usage due to extensive feature set

Code Comparison

itext-dotnet:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

PdfDocument pdf = new PdfDocument(new PdfWriter("output.pdf"));
Document document = new Document(pdf);
document.Add(new Paragraph("Hello, iText!"));
document.Close();

itext-dotnet>:

// No direct code comparison available as itext-dotnet> is not a valid repository name.
// The comparison would depend on the actual repository being referred to.

Note: The code comparison is limited as "itext-dotnet>" is not a valid repository name. The comparison would require the correct repository name to provide an accurate code sample.

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)

Pros of PdfSharpCore

  • Lightweight and focused on PDF creation and manipulation
  • Open-source with a permissive license (MIT)
  • Cross-platform compatibility with .NET Core

Cons of PdfSharpCore

  • Less comprehensive feature set compared to iText
  • Smaller community and potentially slower development pace
  • Limited documentation and examples

Code Comparison

PdfSharpCore:

using PdfSharpCore.Pdf;
using PdfSharpCore.Drawing;

using (var document = new PdfDocument())
{
    var page = document.AddPage();
    var gfx = XGraphics.FromPdfPage(page);
    gfx.DrawString("Hello World!", new XFont("Arial", 20), XBrushes.Black, 20, 50);
    document.Save("output.pdf");
}

iText:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

using (var writer = new PdfWriter("output.pdf"))
using (var pdf = new PdfDocument(writer))
using (var document = new Document(pdf))
{
    document.Add(new Paragraph("Hello World!").SetFontSize(20));
}

Both libraries offer straightforward ways to create simple PDF documents, but iText provides more advanced features and flexibility for complex document generation and manipulation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Logo iText

Nuget AGPL License Nuget GitHub commit activity (branch)

iText Core/Community (previously known as iTextSharp) is a high-performance, battle-tested library that allows you to create, adapt, inspect and maintain PDF documents, allowing you to add PDF functionality to your software projects with ease. It is also available for Java.

The key features of iText Core/Community are:

  • Core library:
    • PDF creation with the use of our layout engine
    • PDF manipulation, e.g. merging multiple PDFs into one, adding new content, ...
    • PDF digital signing
    • PDF form creation and manipulation
    • Working with PDF/A documents
    • Working with PDF/UA documents
    • FIPS-compliant cryptography
    • Barcode generation
    • SVG support
  • Addons:
    • Converting XML/HTML & CSS to PDF repo, info
    • Redacting sensitive information in PDF documents repo, info
    • Support for international character sets (e.g. Arabic, Chinese, Hebrew, Thai, ...) info
    • Optimize PDF documents for reduced file size, and increased performance info
    • Flattening XFA documents info
    • PDF debugging repo, info

Want to discover what's possible? Head over to our Demo Lab! It contains a collection of demo applications ready to use online!

Getting started

The easiest way to get started is to use NuGet, just execute the following install command in the folder of your project:

dotnet add package itext --version <REPLACE_WITH_DESIRED_ITEXT_VERSION>
dotnet add package itext.bouncy-castle-adapter --version <REPLACE_WITH_DESIRED_ITEXT_VERSION>

For more advanced use cases, please refer to the Installation guidelines. You can also build iText Community from source.

Hello PDF!

The following example shows how easy it is to create a simple PDF document:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

namespace HelloPdf {
    class Program {
        static void Main(string[] args) {
            using var document = new Document(new PdfDocument(new PdfWriter("helloworld-pdf.pdf")));
            document.Add(new Paragraph("Hello World!"));
        }
    }
}

Examples

For more advanced examples, refer to our Knowledge Base or the main Examples repo. You can find C# equivalents to the Java Signing examples here, though the Java code is very similar since they have the same API.

Some of the output PDF files will be incorrectly displayed by the GitHub previewer, so be sure to download them to see the correct results.

DescriptionLink
Basic layout
Change text propertiesC#, PDF
Creating a simple tableC#, PDF
Add an image to a PDF documentC#, PDF
Create a listC#, PDF
Add a watermarkC#, PDF
Add links to navigate within a documentC#, PDF
Create a popup annotationC#, PDF
Change fontC#
Add form fieldsC#

General document settings
Change page size and marginC#, PDF
Write PDF to byte array instead of to diskC#
Change page rotationC#, PDF
Add header and footerC#, PDF
Merge documentsC#, PDF
Flatten annotationsC#

PDF/UA, PDF/A
Create PDF/UA documentC#, PDF
Create PDF/A-3 documentC#
Create PDF/A-4 documentC#
Create WTPDF documentC#
Create ZUGFeRD/Factur-X documentC#, PDF

FIPS
Enable FIPSC#
FIPS SHA3 exampleC#

SVG
Convert SVG to a PDFC#
Convert SVG to a PDF using layoutC#
Convert SVG as string to PDFC#
Convert SVG to a PdfPageC#
Convert SVG as XObjectC#
Convert SVG to a PDF with pdfCalligraphC#

Convert HTML and CSS to PDFLink to repo
Convert simple HTML doc to PDFC#

Secure redaction of contentLink to repo
Redacting contentC#
Redact based on regexC#

Support complex writing systemsLink to docs
Add Arabic textC#, PDF

Optimizing PDFsLink to docs
Reduce size of PDFC#

XFA flatteningLink to docs
Flatten an XFA documentC#

RUPSLink to repo
Debug a PDFC#

FAQs, tutorials, etc.

Check out the iText Knowledge Base for the iText Jump-start tutorial and other tutorials, FAQs and more. For specific information and examples relating to digital signatures and iText, make sure to check the Digital Signatures Hub.

Many common questions have already been answered on Stack Overflow, so make sure to also check there.

Contributing

Many people have contributed to iText Core/Community over the years. If you've found a bug, a mistake in documentation, or have a hot new feature you want to implement, we welcome your contributions.

Small changes or fixes can be submitted as a Pull Request, while for major changes we request you contact us at community@apryse.com so we can better coordinate our efforts and prevent duplication of work.

Please read our Contribution Guidelines for details on code submissions, coding rules, and more.

Licensing

iText is dual licensed as AGPL/Commercial software.

AGPL is a free/open-source software license, however, this doesn't mean the software is gratis!

The AGPL is a copyleft license, which means that any derivative work must also be licensed under the same terms. If you’re using iText in software or a service which cannot comply with the AGPL terms, we have a commercial license available that exempts you from such obligations.

Contact Sales for more info.