How to Draw Text and Bitmap on PDFs in C#

How to Draw Text & Bitmap on PDFs using C#

IronPDF enables you to draw text and images on existing PDFs using the DrawText and DrawBitmap methods, allowing customization with watermarks, logos, annotations, and improved visual appearance without altering original content.

Drawing text and images on a PDF involves adding content to an existing document. IronPDF seamlessly enables this feature. By incorporating text and images, you can customize PDFs with watermarks, logos, and annotations, improving the document's visual appearance and branding. Additionally, text and images facilitate information presentation, data visualization, and interactive form creation.

Quickstart: Add Text and Images to PDFs with IronPDF

Start enhancing your PDF documents with text and images quickly and efficiently. Using the DrawText and DrawBitmap methods, you can easily customize PDFs by adding watermarks, logos, or annotations. This example demonstrates how to draw text at specific coordinates and insert an image seamlessly into your PDF.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    new ChromePdfRenderer()
        .RenderHtmlAsPdf("<h1>Doc</h1>")
        .DrawText("Hello World", FontTypes.TimesNewRoman.Name, 12, 0, 100, 100, Color.Black, 0)
        .DrawBitmap(AnyBitmap.FromFile("logo.png"), 0, 50, 250, 500, 300)
        .SaveAs("annotated.pdf");
  3. Deploy to test on your live environment

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


How Do I Draw Text on PDF?

The DrawText method available on the PdfDocument object allows you to add text to an existing PDF without altering its original content. This method is particularly useful for adding dynamic content to PDFs, similar to the stamp text and image feature for more complex overlays.

Understanding Coordinate System

Before drawing text, understand the PDF coordinate system. The origin (0,0) is located at the bottom-left corner of the page, with X values increasing to the right and Y values increasing upward. This differs from many graphics systems where the origin is at the top-left.

:path=/static-assets/pdf/content-code-examples/how-to/draw-text-and-bitmap-draw-text.cs
using IronPdf;
using IronSoftware.Drawing;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");

// Draw text on PDF
pdf.DrawText("Some text", FontTypes.TimesNewRoman.Name, FontSize: 12, PageIndex: 0, X: 100, Y: 100, Color.Black, Rotation: 0);

pdf.SaveAs("drawText.pdf");
$vbLabelText   $csharpLabel

What Fonts Can I Use?

The DrawText method currently supports all Standard Fonts in IronPDF, including Courier, Arial (or Helvetica), TimesNewRoman, Symbol, and ZapfDingbats. Visit the 'Standard Fonts in IronPDF' section in the Manage Fonts article for italic, bold, and oblique variants of these font types.

The ZapfDingbats font can display symbols such as ▲. For a comprehensive list of supported symbols, visit Wikipedia on Zapf Dingbats.

Output fonts sample on PDF

Font samples showing Arial, Courier, Helvetica, and Times New Roman families with bold, italic, and oblique variations

How Can I Add Text with Line Breaks?

The draw text action supports newline characters, allowing you to render text with built-in newlines for better formatting and visual clarity. This is useful when adding multi-line annotations or creating structured text layouts.

To achieve this, add newline characters (\n) to the text string. Using the example above:

// Multi-line text example with proper spacing
string textWithNewlines = "Some text\nSecond line\nThird line with more content";
pdfDoc.DrawText(textWithNewlines, font, position);

// You can also use Environment.NewLine for platform-specific line breaks
string platformText = $"Line 1{Environment.NewLine}Line 2{Environment.NewLine}Line 3";
pdfDoc.DrawText(platformText, font, position);
// Multi-line text example with proper spacing
string textWithNewlines = "Some text\nSecond line\nThird line with more content";
pdfDoc.DrawText(textWithNewlines, font, position);

// You can also use Environment.NewLine for platform-specific line breaks
string platformText = $"Line 1{Environment.NewLine}Line 2{Environment.NewLine}Line 3";
pdfDoc.DrawText(platformText, font, position);
$vbLabelText   $csharpLabel

How Do I Use Custom Fonts?

Custom fonts are supported with the DrawText method, expanding your typography options beyond standard fonts. This feature is essential when maintaining brand consistency or working with specialized fonts. For advanced font management, see our guide on managing fonts in PDFs.

Below is an example with the Pixelify Sans Font added for the text:

:path=/static-assets/pdf/content-code-examples/how-to/draw-text-and-bitmap-draw-custom-font.cs
using IronPdf;
using IronSoftware.Drawing;
using System.IO;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");

// Add custom font to the PDF
byte[] fontByte = File.ReadAllBytes(@".\PixelifySans-VariableFont_wght.ttf");
var addedFont = pdf.Fonts.Add(fontByte);

// Draw text on PDF
pdf.DrawText("Iron Software", addedFont.Name, FontSize: 12, PageIndex: 0, X: 100, Y: 600, Color.Black, Rotation: 0);

pdf.SaveAs("drawCustomFont.pdf");
$vbLabelText   $csharpLabel

Advanced Text Positioning

When positioning text precisely, consider these tips:

  • Page Dimensions: Use pdf.Pages[pageIndex].Width and pdf.Pages[pageIndex].Height to get page dimensions
  • Rotation: The rotation parameter accepts degrees (0-360) for angled text
  • Color Options: Beyond basic colors, use RGB values: Color.FromArgb(255, 100, 100)

How Do I Draw Images on PDF?

IronPDF's DrawBitmap method enables you to add bitmaps to existing PDF documents. This method functions similarly to the Image Stamper feature, allowing you to stamp images onto existing PDFs. For complex image manipulation needs, explore our guide on adding images to PDFs.

Please noteThe DrawBitmap method works best with large images. When using smaller resolution images, you may encounter the following exception: IronPdf.Exceptions.IronPdfNativeException: 'Error while drawing image: data length (567000) is less than expected (756000)'. To overcome this issue, use the Image Stamper, which handles images of all sizes.

Sample image

Iron Software logo with colorful 3D interlocked geometric design on branded background

What Does the Implementation Look Like?

:path=/static-assets/pdf/content-code-examples/how-to/draw-text-and-bitmap-draw-bitmap.cs
using IronPdf;
using IronSoftware.Drawing;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");

// Open the image from file
AnyBitmap bitmap = AnyBitmap.FromFile("ironSoftware.png");

// Draw the bitmp on PDF
pdf.DrawBitmap(bitmap, 0, 50, 250, 500, 300);

pdf.SaveAs("drawImage.pdf");
$vbLabelText   $csharpLabel

Output PDF

What Additional Parameters Are Available?

  • PixelFormat: The PixelFormat property specifies the color data format for the bitmap, primarily controlling transparency support. The default value is Format32bppArgb. Choose between pixel enum formats Format32bppRgb and Format32bppArgb by passing the parameter as an option. This is useful when working with background and foreground elements in PDFs.

  • IgnorePageRotation: This bool property determines whether the method ignores page rotation when drawing the bitmap. By default, the value is false. Especially useful when applying watermarks consistently to all pages, regardless of rotation.

Common Use Cases and Best Practices

When drawing text and images on PDFs, consider these practical applications:

  1. Dynamic Watermarking: Add company logos or "CONFIDENTIAL" stamps to sensitive documents
  2. Page Numbering: Draw page numbers in consistent positions across all pages
  3. Signature Placement: Add signature images at designated locations on forms
  4. Header/Footer Enhancement: Complement existing headers with dynamic content

For debugging and monitoring PDF operations, implement custom logging to track drawing operations and ensure proper execution.

Performance Considerations

When working with multiple pages or large documents:

  • Batch operations when possible to minimize memory usage
  • Dispose of bitmap objects after use to free resources
  • Consider pre-loading frequently used images to improve performance

Ready to see what else you can do? Check out our tutorial page here: Edit PDFs

Frequently Asked Questions

What methods can I use to add text and images to existing PDFs?

IronPDF provides two main methods for adding content to existing PDFs: the DrawText method for adding text and the DrawBitmap method for adding images. These methods allow you to customize PDFs with watermarks, logos, and annotations without altering the original document content.

How does the PDF coordinate system work when drawing text?

In IronPDF, the PDF coordinate system has its origin (0,0) at the bottom-left corner of the page. X values increase moving to the right, and Y values increase moving upward. This differs from many graphics systems where the origin is at the top-left corner.

What fonts are supported when drawing text on PDFs?

IronPDF's DrawText method supports all Standard Fonts including Courier, Arial (Helvetica), Times New Roman, Symbol, and ZapfDingbats. These fonts are also available in italic, bold, and oblique variants. The ZapfDingbats font can be used to display special symbols.

Can I add both text and images to a PDF in a single operation?

Yes, IronPDF allows you to chain methods together. You can use ChromePdfRenderer to create a PDF, then apply DrawText and DrawBitmap methods sequentially in a single line of code, making it efficient to add multiple elements to your PDF document.

What are the common use cases for drawing text and images on PDFs?

IronPDF's drawing capabilities are commonly used for adding watermarks to protect documents, inserting company logos for branding, creating annotations for document review, improving visual appearance, facilitating data visualization, and creating interactive forms.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
Ready to Get Started?
Nuget Downloads 16,901,161 | Version: 2025.12 just released