Product: PDFNetDotNet4
Product Version: 9.4.28.734
Please give a brief summary of your issue:
ToolManager.CreateTool for Stamp
Please describe your issue and provide steps to reproduce it:
We need to give our users the ability to draw rubber stamps on a document. We have a preset list of words on the stamp “APPROVED”, “REVIEW”, etc., plus the user’s name and date of stamp below this. Currently I’m using the following code to do this:
private void StampPage(string stampText)
{
using (var s = new Stamper(Stamper.SizeType.e_absolute_size, 20, 20))
{
var currentPage = _pdfViewer.Current_View.GetCurrentPage();
var doc = _pdfViewer.GetPDFDoc();
var pg = doc.GetPage(currentPage);
var cropBox = pg.GetCropBox();
s.SetOpacity(1);
//s.SetRotation(45);
s.SetAsBackground(true);
s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_left, Stamper.VerticalAlignment.e_vertical_top);
s.SetPosition(40, 40);
s.SetSize(Stamper.SizeType.e_absolute_size, 100, 100);
s.SetAsAnnotation(true);
var stamp = CreateStamp(stampText);
var img = pdftron.PDF.Image.Create(doc.GetSDFDoc(), stamp);
s.StampImage(doc, img, new PageSet(currentPage));
}
_pdfViewer.Current_View.Update(true);
}
The stamp gets created and placed on a hard-coded area of the document when the user clicks a button. But we are being requested to allow the user to draw the stamp by using mouse gestures, like we had before with our older product (prior to using PdfTron). Please see the attached screen clip. We would like it to work similar to how the ToolManager.CreateTool works, like this:
PDFViewViewer view = GetCurrentViewer();
if (view != null)
{
view.ToolManager.AnnotationAdded += ToolManager_AnnotationAdded;
view.ToolManager.CreateTool(pdftron.PDF.Tools.ToolManager.ToolType.e_rect_create, null, true);
}
But with our own custom stamp, preferably with a solid color border, some text in the middle of it, and transparent background inside the rectangle.
CogniVision Workspace 2023-02-17 13-55-27.zip (3.0 MB)