New to Telerik Document ProcessingStart a free 30-day trial

Replace TextBoxField with Image in PDF Document

Updated on Apr 24, 2026
Product VersionProductAuthor
2021.1.212RadPdfProcessingMartin Velikov

Description

How to replace a TextBoxField with an Image in a PDF document.

Solution

In the example below, we are demonstrating how to find a specific TextBoxField by its name in the imported into a RadFixedDocument PDF document, preserve its size and Position and replace it with an Image.

Replace TextBoxField with Image in Imported PDF Document

csharp

RadFixedPage firstPage = document.Pages[0];

    Annotation field = firstPage.Annotations.First(a => ((VariableContentWidget)a).Field.Name == "SampleField");
    Telerik.Documents.Primitives.Rect fieldRect = field.Rect;

    string imagePath = "image.png";
    ImageSource newImageSource;
    using (FileStream source = File.Open(imagePath, FileMode.Open))
    {
        newImageSource = new ImageSource(source);
    }

    SimplePosition simplePosition = new SimplePosition();
    simplePosition.Translate(fieldRect.X, fieldRect.Y);

    Image newImage = new Image
    {
        ImageSource = newImageSource,
        Position = simplePosition,
        Width = fieldRect.Width,
        Height = fieldRect.Height
    };

    firstPage.Annotations.Remove(field);
    firstPage.Content.Add(newImage);	
In this article
DescriptionSolution
Not finding the help you need?
Contact Support