Form Field Image

2 posts, 0 answers
  1. Fadi
    Fadi avatar
    10 posts
    Member since:
    Jul 2013

    Posted 11 Jan Link to this post

    Do you have any sample code to set a form field with an image so that the image is centered in the form field but keeps it's aspect ratio without going outside the bounding box? Does the image need to be resized first to reduce filesize?


  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 12 Jan Link to this post

    Hello Fadi,

    Yes, this is possible. You will need a PushButtonField to hold the image in this case. The image should be smaller than the field rectangle, otherwise, it will be cut off to fit the available size. Here is an example that shows this: 

    RadFixedDocument document = new RadFixedDocument();
    var page = document.Pages.AddPage();
    FormSource form = new FormSource();
    form.Size = new System.Windows.Size(1000, 1000);
    var editor = new FixedContentEditor(form);
    editor.DrawImage(new FileStream(@"..\..\test.png", FileMode.Open));
    PushButtonField pushButtonField = new PushButtonField("Test");
    PushButtonWidget widget = pushButtonField.Widgets.AddWidget();
    widget.Rect = new Rect(25, 25, 805, 612);
    widget.HighlightingMode = HighlightingMode.NoHighlighting;
    widget.AppearanceCharacteristics.Background = new RgbColor(0, 255, 255, 255);
    widget.AppearanceCharacteristics.BorderColor = new RgbColor(0, 255, 255, 255);
    widget.Border = new AnnotationBorder(0, AnnotationBorderStyle.None, null);
    widget.AppearanceCharacteristics.NormalIconSource = form;
    widget.AppearanceCharacteristics.IconAndCaptionPosition = IconAndCaptionPosition.NoCaptionIconOnly;
    widget.AppearanceCharacteristics.IconFitOptions.ScalingType = IconScalingType.Proportional;
    widget.AppearanceCharacteristics.NormalCaption = null;
    PdfFormatProvider provider = new PdfFormatProvider();
    File.WriteAllBytes(@"..\..\result.pdf", provider.Export(document));

    I hope this helps. Should you have any other questions do not hesitate to ask.

    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Back to Top