Skip to content

Commit c356716

Browse files
authored
Merge pull request #3313 from syncfusion-content/Stamp
960253: Add a view for the custom stamp in SfPdfViewer
2 parents b43a0a8 + 28f5aeb commit c356716

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

MAUI/PDF-Viewer/Stamps.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,46 @@ void AddCustomStampAnnotation()
112112
{% endhighlight %}
113113
{% endtabs %}
114114

115+
### Add a view as custom stamps without using the toolbar
116+
117+
You can create a custom stamp from any view, such as Button, Entry, Label, Image, or any other view, and add it to a PDF document. The following example explains how to create a custom stamp from a button view in the application and add it to a PDF document using the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html).
118+
119+
{% tabs %}
120+
{% highlight C# %}
121+
StampAnnotation CreateCustomStamp()
122+
{
123+
int pageNumber = 1;
124+
125+
// Define the bounds for the stamp to be placed in the PDF page.
126+
RectF bounds = new RectF(100, 100, 200, 100);
127+
128+
// Create a button to be used as the visual content of the stamp.
129+
var button = new Button
130+
{
131+
Text = "Click Me",
132+
BackgroundColor = Colors.Blue,
133+
};
134+
135+
// Create a custom stamp annotation using the button view.
136+
StampAnnotation customStamp = new StampAnnotation(button,pageNumber,bounds);
137+
138+
// Return the stamp annotation.
139+
return customStamp;
140+
}
141+
142+
void AddCustomStampAnnotation()
143+
{
144+
StampAnnotation stampAnnotation = CreateCustomStamp();
145+
146+
// Add the stamp to the PDF document using `SfPdfViewer` instance.
147+
PdfViewer.AddAnnotation(stampAnnotation);
148+
}
149+
{% endhighlight %}
150+
{% endtabs %}
151+
152+
N> * The view will be converted as an image in the saved PDF document. The view becomes read only once saved, and its contents cannot be edited after saving the document.
153+
N> * Interactions within the view such as button clicks or text entry will not function inside the PDF Viewer.
154+
115155
## Edit the selected stamp
116156

117157
You can edit the properties of the selected stamp annotation programmatically by accessing the selected annotation instance. The selected annotation instance may be obtained from the [AnnotationSelected](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationSelected) event.

0 commit comments

Comments
 (0)