Click or drag to resize
Placing Stamps

Stamps can be placed on a page using PostToStampRelationForAnnotation of Page, or by using PostToAnnotationRelationForDocumentAnnotations of Document.

Note Note

If Location property of StampPlacement is not specified stamp is automatically placed on the best matching empty region on the page.

Note Note

If the stamp has form fields, then you should specify their values in Field of StampPlacement.

Note Note

If the stamp is password protected you must fill the Password property of StampPlacement with the password of the current user.

Placing a stamp on a page

This example shows how you can place a stamp 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
    {
        public static void PlaceStampOnPage(Page page, string stampId, int layer, DWPoint location)
        {
            var placedStamp = page.PostToStampRelationForAnnotation(new StampPlacement()
            {
                StampId = stampId,
                Layer = layer,
                Location = location,
                Field = new List<FormFieldValue>()
                {
                    new FormFieldValue() { 
                        Name = "<#1>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.DateTime,
                            Item = DateTime.UtcNow,
                        },

                    },
                    new FormFieldValue() { 
                        Name = "<#2>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.Keywords,
                            Item = new DocumentIndexFieldKeywords()
                            {
                                Keyword = new List<string>()
                                {
                                    "qwe",
                                    "123"
                                }
                            }
                        },
                    },
                    new FormFieldValue() {
                        Name = "<#3>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.String,
                            Item = "Some value"
                        }
                    }
                },
            });
        }
    }
}
Placing a stamp on a page from document object

This example shows how you can place a stamp 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
    {
        public static DocumentAnnotations PlaceStampOnDocument(
            this Document document, 
            int sectionNumber, int page, 
            int layer, DWPoint location, string stampId)
        {
            var documentStampPlacement = new DocumentAnnotationsPlacement()
            {
                Annotations = new List<SectionAnnotationsPlacement>()
                {
                    new SectionAnnotationsPlacement()
                    {
                        PageNumber = page,
                        SectionNumber = sectionNumber,
                        AnnotationsPlacement = new AnnotationsPlacement() 
                        { 
                            Items = new List<object>() 
                            { 
                                GetStampPlacement(layer, location, stampId) 
                            }
                        }
                    },
                }
            };

            return document.PostToAnnotationRelationForDocumentAnnotations(documentStampPlacement);
        }

        private static StampPlacement GetStampPlacement(int layer, DWPoint location, string stampId)
        {
            return new StampPlacement()
            {
                StampId = stampId,
                Layer = layer,
                Location = location,
                Field = new List<FormFieldValue>()
                {
                    new FormFieldValue() 
                    { 
                        Name = "<#1>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.DateTime,
                            Item = DateTime.UtcNow,
                        },
                    },
                    new FormFieldValue() 
                    { 
                        Name = "<#2>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.Keywords,
                            Item = new DocumentIndexFieldKeywords()
                            {
                                Keyword = new List<string>()
                                {
                                    "Hotel",
                                    "Booking"
                                }
                            }
                        },
                    },
                    new FormFieldValue() 
                    {
                        Name = "<#3>",
                        TypedValue = new DocumentIndexFieldValue()
                        {
                            ItemElementName = ItemChoiceType.String,
                            Item = "Holidays"
                        }
                    }
                },
            };
        }
    }
}
Retrieve Best Stamp Location

This example shows how you can retrieve best location for a stamp

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
    {
        /// <summary>
        /// Gets the best location for a stamp.
        /// </summary>
        /// <param name="page"></param>
        /// <param name="stamp"></param>
        /// <returns></returns>
        public static DWPoint GetBestStampLocation(Page page, Stamp stamp)
        {
            // get the point of the best position
            var point = page.PostToStampBestPositionRelationForDWPoint(new StampFormFieldValues() { StampId = stamp.Id });

            return point;
        }
    }
}