New to Telerik Document ProcessingStart a free 30-day trial

Replace TextBoxField with Image in PDF Document

Updated on Jun 9, 2026

Environment

VersionProductAuthor
2021.1.212RadPdfProcessingMartin Velikov

Description

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

Solution

The following example finds a specific TextBoxField by its name in a RadFixedDocument imported from PDF, preserves its size and Position, and replaces it with an Image.

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);	

See Also