Apply Rubber Stamp Annotation on all pages

Example requests & Code samples for GdPicture Toolkits.
Post Reply
ejbrandino
Posts: 38
Joined: Thu Sep 22, 2016 4:56 am

Apply Rubber Stamp Annotation on all pages

Post by ejbrandino » Tue Oct 04, 2016 10:44 pm

Hi,

Good day, just want to ask how do you apply rubber stamp annotation on all pages? what is the snippet for looping? Any help would be greatly appreciated.

Thank you very much.

Kind Regards,
Eric

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Apply Rubber Stamp Annotation on all pages

Post by Cedric » Fri Oct 07, 2016 11:17 am

It depends on the document you want to annotate, the code obviously won't be the same with a PDF document or a TIFF document.
In both cases it implies a for loop from 1 to PageCount which can be obtained through the GetPageCount method that exists in both GdPicturePDF and GdPictureImaging classes.
Inside the loop, for each page you need to call the SelectPage method (that exists in both GdPicturePDF and GdPictureImaging classes too), add your annotation and save it to the page.

ejbrandino
Posts: 38
Joined: Thu Sep 22, 2016 4:56 am

Re: Apply Rubber Stamp Annotation on all pages

Post by ejbrandino » Sun Oct 09, 2016 10:41 pm

Hi Cedric, this is what my code looks like, this does the job but obviously it displays all the page one by one upto the last page because of the DisplayPage method, I dont want to display it's page, I just want to apply the stamps automatically on all pages, how do I achieve that? Thank you very much.

for (int i = 1; i <= myViewer.PageCount; i++)
{
myViewer.DisplayPage(i);
AnnotationManager annotMgr = myViewer.GetAnnotationManager();
AnnotationRubberStamp annot = annotMgr.AddRubberStampAnnot(Color.Red, 1.50f, 3.6f, 5.50f, 2.25f, "Lapsed" + Environment.NewLine + lapsedDate);
annot.FontStyle = System.Drawing.FontStyle.Bold;
annot.FontName = "Arial";
annot.BorderWidth = 0.030f;
annot.StrokeColor = Color.Red;
}

Kind Regards,
Eric

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Apply Rubber Stamp Annotation on all pages

Post by Cedric » Wed Oct 12, 2016 10:00 am

That's because you are doing it through the viewer instead of doing it directly onto the input document as advised. The DisplayPage method call does what it is supposed to do, it displays the page.
If you really want to do this in the viewer just set the LockViewer property to true before entering your loop and set it back to false on exit and it should work as you expect.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests