Click or drag to resize
Placing Annotations

Annotations can be placed on a page using PostToAnnotationRelationForAnnotation of Page, or by using PostToAnnotationRelationForDocumentAnnotations of Document.

The Coordinate System

Annotation locations are specified in twips in twips. That is, one inch is 1440 twips and 1 pt is 20 twips.

For example, the top left corner of a page has the coordinates (0,0). The location two inches right and one inch below the top has the coordinates (2880, 1440).

Also the size of elements and font height is specified in twips. A font size of 10 pt is specified as 200 pt.

Placing annotations on a page

This example shows how you can place annotations on a page

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        static public Annotation PlaceAnnotationsOnPage(Page page, int layer)
        {
            var annotations = new Annotation()
            {
                Layer = new List<Layer>()
                {
                    new Layer()
                    {
                        Id = 1,
                        Items = new List<EntryBase>()
                        {
                            //Annotation that contains text
                            new TextEntry()
                            {
                                Location = new AnnotationRectangle() 
                                { 
                                    Left = 100, 
                                    Top = 100, 
                                    Width = 200, 
                                    Height = 200 
                                },
                                Value = "AutoTest",
                                Font = new Font() 
                                { 
                                    FontSize = 10*20, 
                                    FontName = "Arial"
                                }
                            },

                            //Rectangle or Ellipse annotation
                            new RectEntry()
                            {
                                Location = new AnnotationRectangle() 
                                { 
                                    Left = 300, 
                                    Top = 300, 
                                    Width = 200, 
                                    Height = 200 
                                },
                                Filled = true,
                                Ellipse = true,
                            },

                            //Creates a new instance of this class
                            new LineEntry()
                            {
                                From = new AnnotationPoint() { X = 500, Y = 500 },
                                To = new AnnotationPoint() { X = 800, Y = 800 },
                                Arrow = true,
                            }
                        }
                    }
                }
            };

            var placedAnnotations = page.PostToAnnotationRelationForAnnotation(annotations);
            return placedAnnotations;
        }
    }
}
Placing annotations on a page from document object

This example shows how you can place annotations on a page from document object

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        static public DocumentAnnotations PlaceAnnotationsOnDocument(this Document document, int layer)
        {
            var placement = new DocumentAnnotationsPlacement()
            {
                Annotations = new List<SectionAnnotationsPlacement>()
                {
                    new SectionAnnotationsPlacement()
                    {
                        PageNumber = 0,
                        SectionNumber = 0,
                        AnnotationsPlacement = new AnnotationsPlacement() 
                        { 
                            Items = new List<object>() { GetAnnotations(layer) }
                        }
                    },
                    new SectionAnnotationsPlacement()
                    {
                        PageNumber = 1,
                        SectionNumber = 1,
                        AnnotationsPlacement = new AnnotationsPlacement() 
                        { 
                            Items = new List<object>() { GetAnnotations(layer) }
                        }
                    },
                }
            };

            var annotations = document.PostToAnnotationRelationForDocumentAnnotations(placement);
            return annotations;
        }

        private static Annotation GetAnnotations(int layer)
        {
            return new Annotation()
            {
                Layer = new List<Layer>()
                {
                    new Layer()
                    {
                        Id = layer,
                        Items = new List<EntryBase>()
                        {
                            //Annotation that contains text
                            new TextEntry()
                            {
                                Location = new AnnotationRectangle() 
                                { 
                                    Left = 100, 
                                    Top = 100, 
                                    Width = 200, 
                                    Height = 200 
                                },
                                Value = "Holidays",
                                Font = new Font() { FontSize = 10*20, FontName = "Arial", }
                            },

                            //Rectangle or Ellipse annotation
                            new RectEntry()
                            {
                                Location = new AnnotationRectangle() 
                                { 
                                    Left = 300, 
                                    Top = 300, 
                                    Width = 200, 
                                    Height = 200 
                                },
                                Filled = true,
                                Ellipse = true,
                            },

                            //Creates a new instance of this class
                            new LineEntry()
                            {
                                From = new AnnotationPoint() { X = 500, Y = 500 },
                                To = new AnnotationPoint() { X = 800, Y = 800 },
                                Arrow = true,
                            }
                        }
                    }
                }
            };
        }
    }
}