IRONSOFTWAREHOME
PRODUCT COMPARISONS

iTextSharp: Add Image to PDF

Curtis Chau
Curtis Chau
Updated: April 23, 2026

IronPDF offers simpler image addition with fewer lines of code and a perpetual license, while iText provides more granular control but requires more code and has complex licensing under AGPL for commercial use.

When working with PDF files in a .NET environment, adding images to documents is a common requirement for many applications. Whether you're generating invoices with company logos, creating reports with embedded charts, or producing custom documents with watermarks, the ability to embed images into PDFs is essential. Two popular PDF libraries in C# are IronPDF and iText. This article compares both libraries on their ability to add images to PDFs, considering ease of use, performance, licensing models, and advanced features like image compression and format support.

What Are the Key Differences Between IronPDF and iText?

What Image Features Does Each Library Offer?

  • IronPDF: IronPDF simplifies adding images to PDFs with built-in support for both local and remote images from URLs. Its API provides control over position, width, and scaling. The library supports JPEG, PNG, GIF, SVG, and WebGL content. The stamping functionality provides methods for watermarking, letterheads, and overlaying images. The Chrome rendering engine ensures accurate rendering of complex graphics and responsive images.

    iText: iText offers image embedding through its lower-level API. It provides a flexible interface handling JPG and PNG formats. However, you need more code for customization, especially when positioning images precisely or implementing transparency and rotation. The library requires manual handling of coordinate systems and scaling calculations. You often need to implement your own viewport controls for responsive sizing.

How Do They Handle Large Files and Complex Operations?

What Are the Cost Implications for Commercial Use?

How Do I Add Images to PDFs Using IronPDF?

How Do I Install and Configure IronPDF?

Install IronPDF in your C# or Visual Basic project via NuGet. The library supports multiple installation methods including Windows Installer and Docker deployment:

PM > Install-Package IronPdf

Once installed, you can start adding images using IronPDF's API reference. The library works seamlessly across Windows, Linux, and macOS platforms.

What Does Basic Image Addition Look Like in IronPDF?

Quickstart: Add Image to PDF with IronPDF

Adding images to PDFs with IronPDF requires minimal code using the stamping API.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    using IronPdf;
    using IronPdf.Editing;
    
    class Program
    {
        public static void Main(string[] args)
        {
            // Create a renderer to convert HTML to PDF
            ChromePdfRenderer renderer = new ChromePdfRenderer();
            
            // Render a basic PDF with some HTML content
            PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
            
            // Create an ImageStamper with the image URL
            ImageStamper stamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"));
            
            // Configure image position and size
            stamper.HorizontalAlignment = HorizontalAlignment.Center;
            stamper.VerticalAlignment = VerticalAlignment.Middle;
            stamper.Width = 200;  // Width in pixels
            stamper.Height = 100; // Height in pixels
            
            // Apply the stamp (image) to the PDF document
            pdf.ApplyStamp(stamper);
            
            // Save the modified PDF to a file
            pdf.SaveAs("output.pdf");
        }
    }
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

How Can I Add Watermarks and Background Images?

IronPDF excels at adding watermarks and background images to existing PDFs. The library supports multiple stamping operations and custom positioning:

using IronPdf;
using IronPdf.Editing;

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

// Create a watermark with transparency
ImageStamper watermark = new ImageStamper("watermark.png")
{
    Opacity = 30,  // 30% opacity for subtle watermarking
    Rotation = -45, // Diagonal watermark
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Middle
};

// Apply watermark to all pages
pdf.ApplyStamp(watermark);

// Add a header logo
ImageStamper logo = new ImageStamper("company-logo.png")
{
    HorizontalOffset = Length.Millimeters(10),
    VerticalOffset = Length.Millimeters(10),
    Width = 150,
    Height = 50
};

pdf.ApplyStamp(logo, PageSelection.FirstPage);
pdf.SaveAs("watermarked-invoice.pdf");

You can also create complex layouts with multiple images:

// Add images from Base64 strings
string base64Image = Convert.ToBase64String(File.ReadAllBytes("signature.png"));
HtmlStamper signatureStamp = new HtmlStamper($"<img src='data:image/png;base64,{base64Image}'/>");
signatureStamp.HorizontalAlignment = HorizontalAlignment.Right;
signatureStamp.VerticalAlignment = VerticalAlignment.Bottom;
pdf.ApplyStamp(signatureStamp);

PDF viewer showing a simple document with 'Hello World' text and the IronPDF logo watermark centered on the page - demonstrating IronPDF's image stamping feature with precise positioning and opacity control

This example uses the ChromePdfRenderer class to render a new PDF from an HTML string. Using IronPDF's image stamping tool, you create an image from the provided URL and apply it to the PDF. This demonstrates adding images to your PDF page with minimal code. The rendering options provide full control over output quality.

How Can I Control Image Position and Dimensions in IronPDF?

IronPDF provides extensive customization for image placement. You specify page location by setting alignment and offset through the stamping tool's positioning feature. The library supports both absolute positioning with coordinates and relative positioning using alignment options. Advanced features include custom paper sizes and margin control for precise layouts.

How Do I Add Images to PDFs Using iText?

How Do I Install and Configure iText?

Install iText via NuGet. Unlike IronPDF's complete platform support, iText has limited deployment options:

PM > Install-Package itext7

Once configured, proceed to add images using iText's document manipulation features. The library requires additional configuration for font management and UTF-8 support.

What Does Basic Image Addition Look Like in iText?

Here's how to insert an image using iText:

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

class Program
{
    public static void Main(string[] args)
    {
        // Initialize PDF writer
        var pdfWriter = new PdfWriter("output.pdf");
        
        // Initialize PDF document
        var pdfDocument = new iText.Kernel.Pdf.PdfDocument(pdfWriter);
        
        // Initialize document
        var document = new Document(pdfDocument);
        
        // Create ImageData from image file
        ImageData imageData = ImageDataFactory.Create("iText.png");
        
        // Create an Image instance
        Image image = new Image(imageData);
        
        // Set fixed position for the image in the PDF
        image.SetFixedPosition(50, 100);  // x, y coordinates
        
        // Scale image to fit within specified dimensions
        image.ScaleToFit(200, 200);  // Width, Height
        
        // Add image to document
        document.Add(image);
        
        // Close the document
        document.Close();
    }
}

How Can I Add Multiple Images and Handle Complex Layouts?

For complex scenarios like creating product catalogs or photo albums, you manage layout manually. IronPDF's table of contents feature and bookmark support can organize multi-page documents:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.IO.Image;
using iText.Layout.Properties;

// Create a grid of images
var pdfWriter = new PdfWriter("catalog.pdf");
var pdfDocument = new PdfDocument(pdfWriter);
var document = new Document(pdfDocument);

// Add images in a grid layout
float xPosition = 50;
float yPosition = 750;
int imagesPerRow = 3;
int currentImage = 0;

string[] imageFiles = { "product1.jpg", "product2.jpg", "product3.jpg", 
                       "product4.jpg", "product5.jpg", "product6.jpg" };

foreach (string imagePath in imageFiles)
{
    ImageData imageData = ImageDataFactory.Create(imagePath);
    Image image = new Image(imageData);
    
    // Calculate position
    int column = currentImage % imagesPerRow;
    int row = currentImage / imagesPerRow;
    
    float x = xPosition + (column * 180);
    float y = yPosition - (row * 250);
    
    image.SetFixedPosition(x, y);
    image.ScaleToFit(150, 200);
    
    document.Add(image);
    currentImage++;
}

document.Close();

PDF viewer showing a centered iText logo with 'CORE' text on an otherwise blank page - example output of iText's image insertion demonstrating basic positioning and scaling capabilities

The image is added at coordinates (50, 100) and scaled to fit within 200x200 pixels. The PdfWriter creates the output file, enabling PDF writer functionality for handling images. For better organization, consider using page numbers and headers/footers.

How Can I Control Image Position and Dimensions in iText?

iText provides control over positioning and size through manual coordinate calculations. You scale images while maintaining aspect ratio or stretch to specific dimensions. The SetFixedPosition method offers precise placement control, and you can manipulate alignment and rotation. However, it lacks IronPDF's viewport controls and responsive sizing options.

How Do IronPDF and iText Compare in Performance?

Both libraries handle image addition to PDFs with notable differences:

  • IronPDF improved for performance, handling large documents with multiple images efficiently. It renders PDFs faster, especially for graphically intensive documents. The library supports async operations and parallel processing for improved throughput. Memory stream operations reduce disk I/O for better performance.
  • iText offers good performance but may struggle with very large PDFs or numerous high-resolution images. While efficient, some developers report slower rendering times compared to IronPDF in complex use cases involving multiple page operations. The library lacks built-in linearization support for web optimization.

What Are the Advanced Image Features Available?

How Do They Handle Different Image Formats?

IronPDF supports complete image formats:

iText supports standard formats:

  • JPEG/JPG
  • PNG with alpha channel
  • GIF (first frame only)
  • TIFF (single page)
  • BMP and other bitmap formats

What About Image Quality and Compression?

IronPDF provides built-in compression options balancing file size and quality. The library offers sanitization features and flattening capabilities:

// Configure compression when rendering
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.JpegQuality = 85; // 0-100 quality scale

// Compress existing PDFs with images
PdfDocument pdf = PdfDocument.FromFile("large-images.pdf");
pdf.CompressImages(60); // Compress to 60% quality
pdf.SaveAs("compressed.pdf");

// Additional optimization options
renderer.RenderingOptions.GrayScale = true; // Convert to grayscale
renderer.RenderingOptions.DPI = 150; // Reduce DPI for web viewing

iText requires manual compression handling through image data manipulation, increasing implementation complexity for quality controls. You must implement your own grayscale conversion and DPI adjustments.

How Can I Extract Images from Existing PDFs?

IronPDF provides reliable image extraction capabilities:

// Extract all images from a PDF
PdfDocument pdf = PdfDocument.FromFile("document.pdf");
var images = pdf.ExtractAllImages();

foreach (var image in images)
{
    // Save extracted images
    image.SaveAs($"extracted_image_{images.IndexOf(image)}.png");
}

// Extract images from specific pages
var pageImages = pdf.ExtractImagesFromPage(0); // First page

What Are the Licensing and Pricing Models?

Which Library Should I Choose for Adding Images to PDFs?

Feature comparison table between IronPDF and iText PDF libraries showing IronPDF's advantages in ease of use, performance, licensing flexibility, complete image format support, and advanced positioning capabilities for enterprise PDF generation

Both IronPDF and iText provide effective tools for adding images to PDFs in C#, each with distinct advantages. IronPDF excels with ease of use, performance, and licensing flexibility, making it ideal for handling complex PDFs and images with minimal code. It offers better scalability for large PDFs and provides one-time purchase licensing, avoiding recurring costs or complicated open-source restrictions.

The library's support for modern formats like SVG and WebP, combined with built-in compression capabilities and intuitive positioning APIs, suits enterprise applications requiring high-quality document generation. IronPDF's Chrome rendering engine ensures pixel-perfect output across all platforms.

iText suits open-source projects, though requiring more code for equivalent results and potentially facing performance issues with larger PDFs. Its lower-level API provides granular control but increases development complexity. The library lacks modern features like responsive CSS support and JavaScript rendering.

For enterprise applications, IronPDF's advantages include Docker support, AWS Lambda compatibility, and Azure Functions integration. The library also provides PDF/A compliance and PDF/UA accessibility for regulatory requirements.

Ready to simplify your PDF image handling? IronPDF delivers efficient image addition to PDFs with minimal code. Try IronPDF and experience simplified image integration in your C# projects. The implementation handles the complexity for you, saving time and improving your PDF generation workflow. Explore the complete feature set and join thousands of developers who've simplified their PDF operations.

Please note: iText is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by iText. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Related Articles

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999