This example shows how to substitute a text form field with an image.
To accomplish this task it is necessary to remove a certain field with an annotation and substitute it with an image since widget annotations are drawn over the page content.
-
Use the PdfAcroFormFacade.GetFormField method to obtain a required form field. The PdfDocumentFacade.AcroForm property allows you to access the
PdfAcroFormFacade
object. -
Obtain the widget annotations using the PdfFormFieldFacade<T, V>.Widgets property and get the annotation rectangle (defines the annotation location on the page) via the PdfWidgetFacade.Rectangle property. Note that this property is measured in default user space units.
-
Use the PdfWidgetFacade.PageNumber property to get the page where the annotation is located. After that obtain the page boundaries defined by the crop box in the user coordinate system) using the PdfPageTreeObject.CropBox property.
-
To draw an image at the form field position on the page, use the PdfGraphics.DrawImage overload method of the
PdfGraphics
class. -
Call the PdfGraphics.AddToPageForeground overload to add graphics to a page foreground. This method automatically converts world coordinates to page coordinates. Pass
72
as adpi
parameter to this method to transform coordinates without any scaling. -
Call the PdfDocumentProcessor.RemoveFormField method to remove the form field.
-
Use the PdfDocumentProcessor.SaveDocument method to save the resulting document.
- Program.cs (VB: Program.vb)
(you will be redirected to DevExpress.com to submit your response)