Sign In  |  Register  |  About Santa Clara  |  Contact Us

Santa Clara, CA
September 01, 2020 1:39pm
7-Day Forecast | Traffic
  • Search Hotels in Santa Clara

  • CHECK-IN:
  • CHECK-OUT:
  • ROOMS:

iTextSharp

HTML to PDFPhoto from Unsplash

Originally Posted On: https://ironpdf.com/blog/compare-to-other-components/itextsharp/

 

 

iTextSharp C# HTML to PDF Alternative for .NET Core

IronPDF and iText 7 (formerly known as iTextSharp) both provide the ability to generate, manipulate, and print PDFs in .NET and .NET Core.

Which C# PDF library is best suited for your .NET project? The goal of this article is to help readers make a proper and informed decision.

How to Use iTextSharp in C#
  1. Download and install the iTextSharp C# library DLL from GitHub
  2. Include the pdfHTML add-on for enhanced HTML to PDF file conversion
  3. Call the HtmlConverter.ConvertToPDF method to convert an HTML file into a PDF file
  4. Use iTextSharp’s programmatic API to draw text, pictures, charts, and tables into PDF documents
  5. Compare the PDF output with the original HTML document

IronPDF is a prominent .NET PDF library that allows developers to easily create, modify, and interact with PDF documents. It supports various .NET environments, including .NET Core, .NET 8, 7, 6, and Framework, making it highly versatile. Key features of IronPDF include HTML to PDF conversion, merging PDFs, encryption, and digital signatures. The documentation is user-friendly, and technical support is robust.

iTextSharp is a powerful PDF library for the .NET platform, originally derived from iText (which is Java-based). It provides enterprise-level solutions for creating and manipulating PDFs and is available under both open-source (AGPL) and commercial licenses. The iTextSharp core library offers a high degree of flexibility, allowing developers to create PDFs from scratch, manage forms, apply digital signatures, add PDF functionality, and more.

Cross-Platform Compatibility

IronPDF is:

  • .NET First
  • Openly commercial with published pricing
  • Focuses on rendering PDFs from HTML so that developers do not need to learn how PDFs work
  • A great choice for pragmatic coders trying to get a job done.

iText (iTextSharp) is:

  • Java First
  • Very much Open Source. We may call them, for a quote for use other than in strict open source AGLP projects.
  • Focuses on rendering PDFs using a programmatic API based around how PDFs work internally
  • A great choice for free and academic projects

IronPDF supports a wide range of platforms and environments, ensuring seamless integration and deployment in various systems:

iTextSharp has been around for at least 6 years, based on an open-source Java codebase called iText, and still has somewhat of a Java flavor. Developers who first learned Java may find this library familiar.

IronPDF is a .NET-first library with an API designed around ease of use in Visual Studio. .NET has been in existence for almost 20 years, continually growing and expanding, and opening up many possibilities, which IronPDF is designed to leverage. It allows us to create and manipulate PDF documents in .NET framework projects. You can download IronPDF as an alternate PDF library for iTextSharp users.

  • .NET Core (8, 7, 6, 5, and 3.1+)
  • .NET Standard (2.0+)
  • .NET Framework (4.6.2+)
  • App environments: IronPDF works in app environments including Windows, Linux, Mac, Docker, Azure, and AWS
  • IDEs: Works with IDEs such as Microsoft Visual Studio and JetBrains Rider & ReSharper
  • OS and Processors: Supports several different OS & processors including Windows, Mac, Linux, x64, x86, ARM
iTextSharp:
  • .NET versions: Supports .NET Core (2.x, 3.x), .NET Framework (4.6.1+), .NET 5+.
  • App environments: Runs on Windows, macOS, Linux, and Docker.
  • Open Source: Available under AGPL license.
Key Feature Comparison: IronPDF vs. iTextSharp

IronPDF and iTextSharp both offer a range of features and tools that can be used to work with PDF files; the focus of this next section will be to take a closer loo k at some of these features and how the two libraries compare when it comes to carrying out different PDF-related tasks.

IronPDF
  • HTML to PDF Conversion: Supports HTML, CSS, JavaScript, and images.
  • PDF File Manipulation: Split and then merge documents, change the formatting of and edit existing PDF documents
  • Security: PDF encryption and decryption.
  • Editing: Add annotations, bookmarks, and outlines.
  • Templates: Apply headers, footers, and page numbers.
  • Watermarking: Easily apply text and image watermarks to PDF files; take advantage of its use of HTML/CSS to gain full control over the process.
  • PDF Stamping: Stamp images and text onto your PDF documents using IronPDF.

For more information on the extensive set of features IronPDF has to offer, visit the IronPDF features page.

iTextSharp:
  • PDF Creation: Supports creating PDF documents from scratch.
  • Forms: Create and edit PDF forms.
  • Digital Signatures: Sign PDF documents.
  • Compression: Optimize PDF file sizes.
  • Content Extraction: Extract text and images from PDFs.
  • Open Source: Available under AGPL license.
  • Customizability: High level of customization for advanced use cases.
Comparison of PDF Functionality Features Between IronPDF and iTextSharpHTML to PDF Conversion

Converting HTML content into PDF is a very simple task that is done in many different offices and workspaces. Below are the code examples comparing how IronPDF and iText approach this process.

IronPDF

  1. using IronPdf;
  2. // Disable local disk access or cross-origin requests
  3. Installation.EnableWebSecurity = true;
  4. // Instantiate Renderer
  5. var renderer = new ChromePdfRenderer();
  6. // Create a PDF from an HTML string using C#
  7. var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
  8. pdf.SaveAs("output.pdf");
  9. // Advanced Example with HTML Assets
  10. // Load external html assets: images, CSS and JavaScript.
  11. // An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
  12. var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
  13. myAdvancedPdf.SaveAs("html-with-assets.pdf");

iTextSharp

  1. using iText.Html2pdf;
  2. static void Main(string[] args)
  3. {
  4. using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
  5. using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
  6. {
  7. ConverterProperties converterProperties = new ConverterProperties();
  8. HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
  9. }
  10. }

When converting HTML to PDF, IronPDF offers a concise and convenient tool for carrying out this task. Utilizing the ChromePdfRenderer to convert HTML content into PDFs, IronPDF excels in providing users with pixel-perfect PDF documents. Users can create PDFs directly from HTML strings, as shown in the first example, or include external assets like images with an optional base path, as demonstrated in the advanced example. iTextSharp, on the other hand, uses HtmlConverter to convert HTML files, but the process requires more setup.

Encrypting PDF Files

Encryption and decryption of PDF documents are vital at many workplaces. To handle this task easily it’s necessary to have a tool that can do it conveniently. In the code below, we will see how iTextSharp and IronPDF tackle the encryption of PDFs.

IronPDF

  1. using IronPdf;
  2. using System;
  3. // Open an Encrypted File, alternatively create a new PDF from Html
  4. var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
  5. // Edit file metadata
  6. pdf.MetaData.Author = "Satoshi Nakamoto";
  7. pdf.MetaData.Keywords = "SEO, Friendly";
  8. pdf.MetaData.ModifiedDate = DateTime.Now;
  9. // Edit file security settings
  10. // The following code makes a PDF read only and will disallow copy & paste and printing
  11. pdf.SecuritySettings.RemovePasswordsAndEncryption();
  12. pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
  13. pdf.SecuritySettings.AllowUserAnnotations = false;
  14. pdf.SecuritySettings.AllowUserCopyPasteContent = false;
  15. pdf.SecuritySettings.AllowUserFormData = false;
  16. pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
  17. // change or set the document encryption password
  18. pdf.Password = "my-password";
  19. pdf.SaveAs("secured.pdf");

iTextSharp

  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using iText.Kernel.Pdf;
  5. public class EncryptPdf
  6. {
  7. public static readonly String DEST = "results/sandbox/security/encrypt_pdf.pdf";
  8. public static readonly String SRC = "../../../resources/pdfs/hello.pdf";
  9. public static readonly String OWNER_PASSWORD = "World";
  10. public static readonly String USER_PASSWORD = "Hello";
  11. public static void Main(String[] args)
  12. {
  13. FileInfo file = new FileInfo(DEST);
  14. file.Directory.Create();
  15. new EncryptPdf().ManipulatePdf(DEST);
  16. }
  17. protected void ManipulatePdf(String dest)
  18. {
  19. PdfDocument document = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest,
  20. new WriterProperties().SetStandardEncryption(
  21. Encoding.UTF8.GetBytes(USER_PASSWORD),
  22. Encoding.UTF8.GetBytes(OWNER_PASSWORD),
  23. EncryptionConstants.ALLOW_PRINTING,
  24. EncryptionConstants.ENCRYPTION_AES_128 | EncryptionConstants.DO_NOT_ENCRYPT_METADATA
  25. )));
  26. document.Close();
  27. }
  28. }

IronPDF offers users a straightforward way to encrypt PDF files while also giving users plenty of control of the process, including editing metadata and adjusting security settings such as making documents read-only or restricting user actions like copy and paste. On the other hand, iTextSharp provides more granular control but requires additional configuration, such as specifying encryption standards and permissions.

Redact PDF Content

Occasionally, while handling confidential or private information, it may be necessary to redact portions of a PDF file. The following examples demonstrate how you can redact text using IronPDF in comparison with iTextSharp.

IronPDF

  1. using IronPdf;
  2. PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
  3. // Redact 'are' phrase from all pages
  4. pdf.RedactTextOnAllPages("are");
  5. pdf.SaveAs("redacted.pdf");

iTextSharp

  1. using System;
  2. using System.IO;
  3. using iText.Kernel.Pdf;
  4. using iText.Layout;
  5. using iText.Layout.Element;
  6. using iText.Layout.Properties;
  7. using iText.Kernel.Colors;
  8. string src = "input.pdf";
  9. string dest = "output_redacted.pdf";
  10. using (PdfReader reader = new PdfReader(src))
  11. {
  12. using (PdfWriter writer = new PdfWriter(dest))
  13. {
  14. using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
  15. {
  16. // Iterate through each page
  17. for (int pageNum = 1; pageNum <= pdfDoc.GetNumberOfPages(); pageNum++)
  18. {
  19. PdfPage page = pdfDoc.GetPage(pageNum);
  20. PdfCanvas canvas = new PdfCanvas(page);
  21. Rectangle[] rectanglesToRedact = { new Rectangle(100, 100, 200, 50) }; // Example: Define rectangles to redact
  22. // Overlay black rectangles to simulate redaction
  23. foreach (Rectangle rect in rectanglesToRedact)
  24. {
  25. canvas.SetFillColor(ColorConstants.BLACK)
  26. .Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
  27. .Fill();
  28. }
  29. }
  30. }
  31. }

IronPDF’s redaction tool is concise and easy to use, needing only a few lines of code to streamline the redaction process. This helps raise efficiency around PDF redaction tasks and gives users an easy way to keep their sensitive and private data safe.

On the other hand, iTextSharp lacks a built-in redaction feature, requiring you to manually draw black rectangles over the content you wish to redact. However, this approach can leave the text under the rectangle accessible, allowing users to copy-paste the hidden data, so it doesn’t provide true redaction.

Signing PDF documents

Being able to sign digital documents such as PDF files and then making it an automated process could be time saving. The following code snippets compare how IronPDF and iTextSharp handle digital signatures.

IronPDF

  1. using IronPdf;
  2. using IronPdf.Signing;
  3. using System.Security.Cryptography.X509Certificates;
  4. // Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
  5. X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
  6. // Create PdfSignature object
  7. var sig = new PdfSignature(cert);
  8. // Sign PDF document
  9. PdfDocument pdf = PdfDocument.FromFile("document.pdf");
  10. pdf.Sign(sig);
  11. pdf.SaveAs("signed.pdf");

iTextSharp

  1. using System;
  2. using System.IO;
  3. using iText.Kernel.Pdf;
  4. using iText.Signatures;
  5. using Org.BouncyCastle.Crypto;
  6. using Org.BouncyCastle.Pkcs;
  7. using Org.BouncyCastle.X509;
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string src = "input.pdf";
  13. string dest = "output_signed.pdf";
  14. string pfxFile = "your_certificate.pfx";
  15. string pfxPassword = "your_password";
  16. try
  17. {
  18. // Load your certificate
  19. Pkcs12Store ks = new Pkcs12Store(new FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray());
  20. string alias = null;
  21. foreach (string al in ks.Aliases)
  22. {
  23. if (ks.IsKeyEntry(al))
  24. {
  25. alias = al;
  26. break;
  27. }
  28. }
  29. ICipherParameters pk = ks.GetKey(alias).Key;
  30. X509CertificateEntry[] chain = ks.GetCertificateChain(alias);
  31. X509Certificate2 cert = new X509Certificate2(chain[0].Certificate.GetEncoded());
  32. // Create output PDF with signed content
  33. using (PdfReader reader = new PdfReader(src))
  34. {
  35. using (PdfWriter writer = new PdfWriter(dest))
  36. {
  37. using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
  38. {
  39. // Create the signer
  40. PdfSigner signer = new PdfSigner(pdfDoc, writer, new StampingProperties().UseAppendMode());
  41. // Configure signature appearance
  42. PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
  43. appearance.SetReason("Digital Signature");
  44. appearance.SetLocation("Your Location");
  45. appearance.SetContact("Your Contact");
  46. // Create signature
  47. IExternalSignature pks = new PrivateKeySignature(pk, "SHA-256");
  48. signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
  49. }
  50. }
  51. }
  52. Console.WriteLine($"PDF digitally signed successfully: {dest}");
  53. }
  54. catch (Exception ex)
  55. {
  56. Console.WriteLine($"Error signing PDF: {ex.Message}");
  57. }
  58. }
  59. }

When applying signatures to PDF files digitally, IronPDF presents a condense yet powerful tool for completing this process. Its simplicity allows for the process to be conducted quickly, saving time for any developer who implements it for their signing needs. In contrast, iTextSharp requires more setup and involves additional steps to handle digital signatures, making it more complex, though potentially more flexible for advanced users.

Applying Watermarks to PDF documents

The ability to add and personalize watermarks on PDFs through software can greatly assist with confidentiality, copyright protection, branding or any other tasks involving sensitive information. The following is a comparison of how IronPDF and iTextSharp apply watermarks to PDF files.

IronPDF

  1. using IronPdf;
  2. // Stamps a Watermark onto a new or existing PDF
  3. var renderer = new ChromePdfRenderer();
  4. var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
  5. pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
  6. pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");

iTextSharp

  1. using iText.IO.Font;
  2. using iText.IO.Font.Constants;
  3. using iText.Kernel.Colors;
  4. using iText.Kernel.Font;
  5. using iText.Kernel.Pdf;
  6. using iText.Kernel.Pdf.Canvas;
  7. using iText.Kernel.Pdf.Extgstate;
  8. using iText.Layout;
  9. using iText.Layout.Element;
  10. using iText.Layout.Properties;
  11. public class TransparentWatermark
  12. {
  13. public static readonly String DEST = "results/sandbox/stamper/transparent_watermark.pdf";
  14. public static readonly String SRC = "../../../resources/pdfs/hero.pdf";
  15. public static void Main(String[] args)
  16. {
  17. FileInfo file = new FileInfo(DEST);
  18. file.Directory.Create();
  19. new TransparentWatermark().ManipulatePdf(DEST);
  20. }
  21. protected void ManipulatePdf(String dest)
  22. {
  23. PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
  24. PdfCanvas under = new PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), new PdfResources(), pdfDoc);
  25. PdfFont font = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA));
  26. Paragraph paragraph = new Paragraph("This watermark is added UNDER the existing content")
  27. .SetFont(font)
  28. .SetFontSize(15);
  29. Canvas canvasWatermark1 = new Canvas(under, pdfDoc.GetDefaultPageSize())
  30. .ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
  31. canvasWatermark1.Close();
  32. PdfCanvas over = new PdfCanvas(pdfDoc.GetFirstPage());
  33. over.SetFillColor(ColorConstants.BLACK);
  34. paragraph = new Paragraph("This watermark is added ON TOP OF the existing content")
  35. .SetFont(font)
  36. .SetFontSize(15);
  37. Canvas canvasWatermark2 = new Canvas(over, pdfDoc.GetDefaultPageSize())
  38. .ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
  39. canvasWatermark2.Close();
  40. paragraph = new Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")
  41. .SetFont(font)
  42. .SetFontSize(15);
  43. over.SaveState();
  44. // Creating a dictionary that maps resource names to graphics state parameter dictionaries
  45. PdfExtGState gs1 = new PdfExtGState();
  46. gs1.SetFillOpacity(0.5f);
  47. over.SetExtGState(gs1);
  48. Canvas canvasWatermark3 = new Canvas(over, pdfDoc.GetDefaultPageSize())
  49. .ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
  50. canvasWatermark3.Close();
  51. over.RestoreState();
  52. pdfDoc.Close();
  53. }
  54. }

IronPDF’s easy and intuitive API lets users apply custom watermarks to their PDF files quickly, while giving them full control over the process. Its use of HTML/CSS further simplifies the process without losing any control over the customization. iTextSharp’s approach to adding watermarks to PDFs requires more manual work to carry out the task, which can slow the process down.

Stamping Images and Text onto a PDF

There are moments when PDF pages need to be stamped with content, similar to how one might need to apply watermarks to their PDF files. Let’s see how IronPDF compares with iTextSharp:

IronPDF

  1. using IronPdf;
  2. using IronPdf.Editing;
  3. ChromePdfRenderer renderer = new ChromePdfRenderer();
  4. PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
  5. // Create text stamper
  6. TextStamper textStamper = new TextStamper()
  7. {
  8. Text = "Text Stamper!",
  9. FontFamily = "Bungee Spice",
  10. UseGoogleFont = true,
  11. FontSize = 30,
  12. IsBold = true,
  13. IsItalic = true,
  14. VerticalAlignment = VerticalAlignment.Top,
  15. };
  16. // Stamp the text stamper
  17. pdf.ApplyStamp(textStamper);
  18. pdf.SaveAs("stampText.pdf");
  19. // Create image stamper
  20. ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
  21. {
  22. VerticalAlignment = VerticalAlignment.Top,
  23. };
  24. // Stamp the image stamper
  25. pdf.ApplyStamp(imageStamper, 0);
  26. pdf.SaveAs("stampImage.pdf");

iTextSharp

  1. using iText.Kernel.Pdf;
  2. using iText.Layout;
  3. using iText.Layout.Element;
  4. public void StampPDF(string inputPdfPath, string outputPdfPath, string stampText)
  5. {
  6. PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputPdfPath), new PdfWriter(outputPdfPath));
  7. var document = new Document(pdfDoc);
  8. ...
  9. }

By quickly glancing at the code, you can see that IronPDF is pragmatic, based on common end-user requirements.

iText is a lower-level library that focuses on a drawing API where we add objects, shapes, and text to pages.

iTextSharp.dll uses a primarily programmatic model to render PDFs. When using the iTextSharp PDF library, each piece of PDF text, graphic, table, or line is “plotted” or drawn onto a PDF. The API appears low-level and is focused on the PDF document standard. This model allows precision but may require developers to learn a little about how PDFs work. Closely matching an existing design style or web assets may take some iteration and reading the iTextSharp documentation. In keeping with its heritage, the methodology and programmatic interface have a distinct Java flavor.

In contrast, IronPDF uses a full embedded web browser renderer to convert HTML to PDF. Following short (1- and 2-line) C# code examples for HTML to PDF conversion, developers can generate PDFs from existing or new HTML, images, and CSS. This allows developers to work closely with existing web assets and also work in parallel with designers during a project. iText does include HTML to PDF functionality for C# .NET, though it is not, apparently, the library’s dominant feature.

Read on for more comparative details on the different ways that IronPDF and iTextSharp can help developers achieve the following goals:

1. Licensing

Licensing options are also an important factor in developer projects. iTextSharp is Open Source under the AGPL license agreement. When licensed under AGLP, anyone who uses any part of an application that contains iTextSharp (even across a company network or the internet) may be entitled to a full copy of the app’s full source code. This is excellent for academic work. If we wish to use iTextSharp in commercial applications it is best practice to contact iText and ask them for a quote on the pricing for iText commercial usage.

IronPDF is free for development, and can then be licensed for commercial deployment at publicly published, reasonable prices starting at $749.

IronPDF and iTextSharp

This is how the two libraries stack up:

IronPDFiTextSharp
Convert HTML to PDF via a full built-in web browserBasic HTML to PDF via a pdfHTML add-on
Rendering focus: Embedded web browserRendering focus: Programmatic drawing model
IronPDF has explicit licenses with published pricesAGPL! Commercial use pricing not published.
Easy to Code with .NET First DesignBased on a Java API
Not suited to academic assignments and coursework Excellent for academic assignments and research

Key DifferencesGenerate PDF from HTML using IronPDF

IronPDF enables .NET and .NET Core developers to generate, merge, split, edit, and extract PDF content easily in C#, F#, and VB.NET for .NET Core and .NET Framework, as well as create PDFs from HTML, ASPX, CSS, JS, and image files.

It makes use of a fully embedded web browser to convert HTML to PDF. This allows developers to generate PDFs from HTML, images, and CSS, and to work closely with existing web assets and also work in parallel with designers during a project.

2. IronPDF Features

IronPDF really focuses on developer productivity. The library simplifies many common complex PDF code tasks into convenient C# methods to extract text and images, sign PDFs, edit PDFs with new HTML, and more, without the developer needing to study the PDF document standard to understand how to achieve their best result.

  • Generating PDF documents from HTML, images, and ASPX files
  • Reading PDF text
  • Extracting data and images from PDFs
  • Merging PDF documents
  • Splitting PDFs
  • Manipulating PDFs
2. iTextSharp Documentation Features

The iTextSharp.dll uses a primarily programmatic model to render PDFs, and it has advanced PDF manipulation APIs that are powerful and follow the PDF standard closely.

  • AGLP strict open source licensing
  • Programmatic drawing model
  • Edit and Read PDFs
  • Solid functionality for PDF manipulation
  • Based on a Java library

Let’s compare by creating an example project utilizing both libraries:


Example ProjectCreate an ASP.NET Project

Make use of the following steps to create an ASP.NET website:

  1. Open Visual Studio
  2. Click File > New Project
  3. Select Web under Visual C# in the Project type listbox
  4. Select ASP.NET Web Application

New Project related to Create an ASP.NET ProjectFigure 1New Project

  • Click OK
  • On the next screen, select Web Forms as shown in Figure 2 underneath

Web Form related to Create an ASP.NET ProjectFigure 2Web Forms

  • Click OK

Now we have something to work with. Let’s Install IronPDF.


Get Started3. IronPDF Library Installation

In order to make use of IronPDF, you first need to install it (free). There are two options:

  • NuGet
  • Download the library

Let’s have a closer look.

3.1. Install using NuGet

There are three ways to install the IronPDF NuGet package:

  1. Visual Studio
  2. Developer Command Prompt
  3. Download the NuGet Package directly

Let’s do them one-by-one.

3.2. Visual Studio

Visual Studio provides the NuGet Package Manager for you to install NuGet packages in your projects. You can access it via the Project Menu, or by right-clicking your project in the Solution Explorer. Both these options are shown below in Figures 3 and 4

Project Menu related to 3.2. Visual StudioFigure 3Project menu

Solution Explorer related to 3.2. Visual StudioFigure 4Right-click Solution Explorer

After you have clicked Manage NuGet Packages from either option, Browse for the IronPDF package and install it as shown in Figure 5.

Install Ironpdf Nuget Package related to 3.2. Visual StudioFigure 5Install IronPDF NuGet Package

3.3. Developer Command Prompt

The following steps open the Developer Command Prompt and installs the IronPDF NuGet package

  1. Search for your Developer Command Prompt – it is usually under your Visual Studio folder
  2. Type in the following command: PM > Install-Package IronPdf
  3. Press Enter
  4. The package will be installed
  5. Reload your Visual Studio project
3.4. Download the NuGet Package directly

In order to download the NuGet package:

  1. Navigate to https://www.nuget.org/packages/IronPdf/
  2. Click on Download Package
  3. After the package has downloaded, double click it
  4. Reload your Visual Studio project
3.5. Download the .DLL Library

The second way to install IronPDF is by direct download.

Download Ironpdf Library related to 3.5. Download the .DLL LibraryFigure 6Download IronPDF library

Reference the Library in your project by using the next steps:

  1. Right-click the Solution in the Solution Explorer
  2. Select References
  3. Browse for the IronPDF.dll library
  4. Click OK

Now that you’re set up, we can start playing with the awesome features in the IronPDF library after the setup for iTextSharp.

Install iTextSharp by using NuGet

There are three ways to install the iTextSharp NuGet package, they are:

  • Visual Studio
  • Developer Command Prompt
  • Download the NuGet Package directly

Let’s do them one-by-one.

For Visual Studio, search for iText and install the relevant packages, as shown next.

Itext related to Install iTextSharp by using NuGetFigure 7iText

Or, in the Developer Command Prompt (as shown previously, enter the following command)

  • PM > Install-Package itext7

Or, download iText 7 directly from their website.

Now that you have created the necessary projects, let’s compare these two libraries in code.


Compare the Code4. Create a PDF from an Existing URL

The following code downloads a webpage and converts it to a PDF document.

4.1. IronPDF Website to PDF

The following code uses IronPDF to create a PDF document directly from a website address. Custom Headers and Footers are also included.

  1. /**
  2. IronPDF URL to PDF
  3. anchor-ironpdf-website-to-pdf
  4. **/
  5. private void ExistingWebURL()
  6. {
  7. // Create a PDF from any existing web page
  8. var Renderer = new IronPdf.ChromePdfRenderer();
  9. // Create a PDF from an existing HTML
  10. Renderer.RenderingOptions.MarginTop = 50; //millimetres
  11. Renderer.RenderingOptions.MarginBottom = 50;
  12. Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
  13. Renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
  14. {
  15. CenterText = "{pdf-title}",
  16. DrawDividerLine = true,
  17. FontSize = 16
  18. };
  19. Renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
  20. {
  21. LeftText = "{date} {time}",
  22. RightText = "Page {page} of {total-pages}",
  23. DrawDividerLine = true,
  24. FontSize = 14
  25. };
  26. Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
  27. Renderer.RenderingOptions.EnableJavaScript = true;
  28. Renderer.RenderingOptions.RenderDelay = 500; //milliseconds
  29. using var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
  30. PDF.SaveAs("wikipedia.pdf");
  31. }

IronPDF can help you add text or images onto PDFs in a way that’s really versatile and customizable; it lets you take complete charge. It is easy to understand and work with the API, especially for developers familiar with HTML/CSS. iTextSharp makes use of its image and text stamping tools to give users more control over the content displayed on their PDF files, although the process can end up being more manual.

Convert DOCX to PDF

Sometimes, you might have to convert PDFs from one format to the other. In this case, we looking at DOCX to PDF conversion and comparing how IronPDF and iTextSharp handle this process differently.

IronPDF

  1. using IronPdf;
  2. // Instantiate Renderer
  3. DocxToPdfRenderer renderer = new DocxToPdfRenderer();
  4. // Render from DOCX file
  5. PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
  6. // Save the PDF
  7. pdf.SaveAs("pdfFromDocx.pdf");

iTextSharp

Unfortunately, iTextSharp does not provide built-in DOCX to PDF conversion functionality, and developers must rely on external libraries like Aspose.Words for this task.

IronPDF provides developers with a straightforward and concise tool for handling DOCX to PDF conversion tasks, making it easy to convert DOCX files to a PDF format with the need for external libraries. iTextSharp, on the other hand, relies on external libraries in order to carry out this task.

Summary of the Code Examples Comparison

Itextsharp 1 related to Summary of the Code Examples Comparison

For more detailed examples, visit IronPDF Examples.

Pricing and Licensing: IronPDF vs. iTextSharp LibraryIronPDF Pricing and Licensing

IronPDFhas different levels and additional features for purchasing a license. Developers can also buy Iron Suite which, gives you access to all of Iron Software’s products at the price of two. If you’re not ready to buy a license, IronPDF provides a free trial that lasts 30 days.

  • Perpetual licenses: Offers a range of perpetual licenses depending on the size of your team, your project needs, and the number of locations. Each license type comes with email support.
  • Lite License: This license costs $749 and supports one developer, one location, and one project.

With this code segment, we have transformed the Tiger Wikipedia webpage to PDF with both libraries.

  • Professional License: This license is suitable for larger teams, supporting ten developers, ten locations, and ten projects for $2,999. It offers the same contact support channels as the previous tiers but also offers screen-sharing support.
  • Royalty-free redistribution: IronPDF’s licensing also offers royalty-free redistribution coverage for an extra $1,999
  • Uninterrupted product support: IronPDF offers access to ongoing product updates, security feature upgrades, and support from their engineering team for either $999/year or a one-time purchase of $1,999 for a 5-year coverage.
  • Iron Suite: For $1,498, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper.

Itextsharp 2 related to IronPDF Pricing and Licensing

iTextSharp Licensing
  • AGPL License: iTextSharp is available for free under the AGPL (Affero General Public License). This license requires that any software using iTextSharp be open-source under the same license if it is redistributed.
  • Commercial License: For projects that don’t meet AGPL terms, iTextSharp offers a commercial license to allow its use in proprietary software. Pricing for this license is based on a quote-based model and varies depending on the usage and scope of the project.
Documentation and Support: IronPDF vs. iTextIronPDF
  • Comprehensive Documentation: Extensive and user-friendly documentation covering all the features it has to offer.
  • 24/5 Support: Active engineer support is available.
  • Video Tutorials: Step-by-step video guides are available on YouTube.
  • Community Forum: Engaged community for additional support.
  • Regular Updates: Monthly product updates to ensure the latest features and security patches.
iTextSharp
  • Documentation: iTextSharp offers detailed documentation covering its key functionalities.
  • Examples and Tutorials: A variety of tutorials and code examples are provided to help developers get started.
  • GitHub: Developers can submit issues or bugs to the iTextSharp GitHub repository and interact with the iTextSharp community for support.
  • Updates: Regular updates are provided to improve features and address bugs.

For more details on IronPDF documentation and support, visit IronPDF Documentation and the Iron Software YouTube Channel.

Conclusion

Both IronPDF and iTextSharp are solid options for PDF manipulation in .NET projects. IronPDF distinguishes itself with its intuitive platform integration and features like HTML-to-PDF conversion and advanced security options. iTextSharp, while rooted in the open-source iText library, offers a powerful and flexible toolset under the AGPL and commercial licenses, making it ideal for projects that can benefit from open-source flexibility or require strict licensing compliance.

Choosing the right tool depends on your project’s licensing requirements, technical support needs, and specific feature demands. Whether you favor the simplicity and comprehensive support of IronPDF or the open-source robustness of iTextSharp, both libraries offer developers ample resources to enhance PDF workflows in their applications.

Stock Quote API & Stock News API supplied by www.cloudquote.io
Quotes delayed at least 20 minutes.
By accessing this page, you agree to the following
Privacy Policy and Terms and Conditions.
 
 
Copyright © 2010-2020 SantaClara.com & California Media Partners, LLC. All rights reserved.