A couple of question:
1) after adding a stamper to a page, I don't see it. If a save, close and re-open that file, I see it. How can I see that stamper as soon as I have added it to a page?
2) The method SetPosition(x, y) it seems to be not precise. I post my code hereafter to verify if I have missed something. Please note that I have a button to choose the stamp image, and after the click event, I call a second event on mouse down in order to have the correct position where I have to add, as annotation, that image/stamp. But that stamp appear at a wrong place, w.r.t. the mouse position.
private void btnPass_Clicked(object sender, RoutedEventArgs e)
{
PDFViewViewer view = GetCurrentViewer();
if (view != null)
{
view.MouseDown += view_MouseDown;
}
}
void view_MouseDown(object sender, MouseButtonEventArgs e)
{
PDFViewViewer view = (PDFViewViewer) sender;
PDFDoc doc = view.GetPDFDoc();
if (doc != null)
{
System.Windows.Point position = e.GetPosition(view);
double x = position.X;
double y = position.Y;
view.Current_View.ConvScreenPtToPagePt(ref x, ref y, view.GetCurrentPageNumber());
using (Stamper s = new Stamper(Stamper.SizeType.e_absolute_size, 32, 32))
{
Image img = Image.Create(doc, @"..\..\Images\Pass.png");
s.SetAsBackground(false);
s.SetPosition(x, y);
s.SetAsAnnotation(true);
s.StampImage(doc, img, new PageSet(view.GetCurrentPageNumber()));
}
}
}