Dynamic Location of a Stamp

Dynamic Location of a Stamp

Forum member · Jul 13, 2006
Is there anyway to dynamically position a stamp in the center of each page, when page sizes (A4, A3, A2, Letter etc...) and orientation vary. I have noticed that you can get the stamp to be centered on each page quite easily (that’s providing all pages are of the same size and orientation). However I have one document which has a variation of different size pages and some are Landscape as well as portrait. e.g. The stamp needs to be centered on each page at an angle of 45 degrees Page 1: Size: A4 Orientation: Portrait ------------------------- Page 2: Size: A3 Orientation: Landscape ------------------------- Page 3: Size: A2 Orientation: Portrait ------------------------- Page 4: Size: A4 Orientation: Landscape ------------------------- Page 5: Size: A5 Orientation: Portrait ------------------------- Is there any method / example script that detects the properties of each page and stamps accordingly? Thanks, Tom

Re: Dynamic Location of a Stamp

Support · Jul 13, 2006
Hello Tom, Yes, you can stamp the pages at the center position without any problem irrespective of the size or the orientation of the page. You can find the height and width of a page by using the page.Dimensions.Height and page.Dimensions.Width properties and then based on those values stamp the PDF page accordingly by calculating the center. Thanks, ceTe Software Support Team

Re: Dynamic Location of a Stamp

Support · Jul 13, 2006
Hello Tom, The easiest way to center the positioning of the stamp would be by using the AnchorGroup page element. The constructor takes horizontal and vertical alignment which can be set to Center and this will work for any page size and orientation. Thanks, ceTe Software Support Team

Re: Dynamic Location of a Stamp

Forum member · Jul 13, 2006
Thanks for the quick reply. Regarding the utilization of the AnchorGroup Constructor. Do you have any examples of this? I've checked the CeTe Software Help Library for .NET, but cannot find any examples. Regards, Tom

Re: Dynamic Location of a Stamp

Support · Jul 13, 2006
Hello Tom, Following is a sample C# code which will allow you to stamp the PDF at the center of the page using the AnchorGroup page element: Code: MergeDocument document = new MergeDocument(@"C:\Temp\DocumentA.pdf"); AnchorGroup gp = new AnchorGroup(100,20,Align.Center,VAlign.Center); gp.Add(new Label("Hello added",0,0,100,20)); for(int i=0; i<document.Pages.Count; i++) { document.Pages[i].Elements.Add(gp); } document.DrawToWeb(); Thanks, ceTe Software Support Team

Re: Dynamic Location of a Stamp

Forum member · Jul 13, 2006
Thanks for the help! one last thing..... It this possible to use the TransparencyGroup with my scenario? If so how can this be accomplished? Thanks again, Tom

Re: Dynamic Location of a Stamp

Support · Jul 13, 2006
Hello Tom, Yes, you can add any page element including the TransparencyGroup to the AnchorGroup page element. In this case you will first add the page elements to the TransparencyGroup and then add the TransparencyGroup to AnchorGroup. Following is the modified code block: MergeDocument document = new MergeDocument(@:"C:\Temp\DocumentA.pdf"); TransparencyGroup group = new TransparencyGroup(0.5f); group.Add(new Label("Hello added",0,0,100,20)); //Add label to TransparencyGroup AnchorGroup gp = new AnchorGroup(100,20,Align.Center,VAlign.Center); gp.Add(group); //Add TransparencyGroup to AnchorGroup for(int i=0; i<document.Pages.Count; i++) { document.Pages[i].Elements.Add(gp); } document.DrawToWeb(); Thanks, ceTe Software Support Team

Re: Dynamic Location of a Stamp

Forum member · Jul 13, 2006
Perfect!!!! Thanks very much for your help. Regards, Tom