Add image annotation

On this page

Image annotation allows you to add an image on document page as shown in the picture below:

You can set the following properties of the ImageAnnotation class:

  • ImagePath defines the image local or remote path
  • Box defines the annotation position on the page using the Rectangle structure (image will be resized for specified width and height)
  • Opacity allows you to set the annotation opacity (present in all supported formats, examples of it you can see above)
  • Angle defines the annotation rotation angle

To add an image annotation, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the ImageAnnotation class. Specify the appropriate properties (position, page number, etc).
  3. Call the Add method. Specify the ImageAnnotation class.
  4. Call the Save method. Specify the output document path or stream.

The following code snippet shows how to add ImageAnnotation to the document:

using (Annotator annotator = new Annotator("input.pdf"))
            {
                ImageAnnotation area = new ImageAnnotation
                {
                    Box = new Rectangle(100, 100, 100, 100),
                    Opacity = 0.7,
                    PageNumber = 0,
                    ImagePath = "www.google.com.ua/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png",
                    Angle = 100
                };
                annotator.Add(area);
                annotator.Save("result.pdf");
            }

On this page