private static Annot setStamperImage(StamperImage stp) { var page = _currentDoc.GetPage(stp.Page()); using (pdftron.PDF.Stamper s = new pdftron.PDF.Stamper(pdftron.PDF.Stamper.SizeType.e_relative_scale, .5, .5)) { s.SetAsAnnotation(true); var rect = AnnotationsMannager.ConvertRect(stp.RectArea()); _currentDoc.InitSecurityHandler(); //pdftron.PDF.Image img = pdftron.PDF.Image.Create(_currentDoc, String.IsNullOrEmpty(stp.ImagePath()) ? "SuccessStamp.jpg" : stp.ImagePath()); pdftron.PDF.Image img = pdftron.PDF.Image.Create(_currentDoc, System.Convert.FromBase64String(stp.Image())); s.SetTextAlignment(pdftron.PDF.Stamper.TextAlignment.e_align_center); s.SetAlignment(pdftron.PDF.Stamper.HorizontalAlignment.e_horizontal_left, pdftron.PDF.Stamper.VerticalAlignment.e_vertical_bottom); s.SetSize(pdftron.PDF.Stamper.SizeType.e_absolute_size, rect.x2 - rect.x1, rect.y2 - rect.y1); s.SetPosition(rect.x1, rect.y1); s.SetAsBackground(false); s.SetOpacity(.3); s.StampImage(_currentDoc, img, new PageSet(stp.Page())); } var annot = page.GetAnnot(page.GetNumAnnots() - 1); stp.RectArea(AnnotationsMannager.ConvertRect(annot.GetRect())); return(annot); }
private static Annot setStamperText(StamperText stp) { var page = _currentDoc.GetPage(stp.Page()); using (pdftron.PDF.Stamper s = new pdftron.PDF.Stamper(pdftron.PDF.Stamper.SizeType.e_relative_scale, .5, .5)) { s.SetAsAnnotation(true); var rect = AnnotationsMannager.ConvertRect(stp.RectArea()); _currentDoc.InitSecurityHandler(); s.SetTextAlignment(pdftron.PDF.Stamper.TextAlignment.e_align_center); s.SetAlignment(pdftron.PDF.Stamper.HorizontalAlignment.e_horizontal_left, pdftron.PDF.Stamper.VerticalAlignment.e_vertical_bottom); s.SetFontColor(new ColorPt(stp.ColorRed(), stp.ColorGreen(), stp.ColorBlue())); s.SetSize(pdftron.PDF.Stamper.SizeType.e_absolute_size, rect.x2 - rect.x1, rect.y2 - rect.y1); s.SetPosition(rect.x1, rect.y1); s.SetAsBackground(false); s.SetOpacity(.3); s.StampText(_currentDoc, String.IsNullOrEmpty(stp.Text()) ? "Sample Text" : stp.Text(), new PageSet(stp.Page())); } var annot = page.GetAnnot(page.GetNumAnnots() - 1); stp.RectArea(AnnotationsMannager.ConvertRect(annot.GetRect())); return(annot); }