@@ -33,23 +33,29 @@ public MainWindow()
33
33
path = "../../../Data/" ;
34
34
#endif
35
35
pdfViewer . Load ( System . IO . Path . Combine ( path , "F#.pdf" ) ) ;
36
+ pdfViewer . DocumentLoaded += PdfViewer_DocumentLoaded ;
36
37
}
37
- /// <summary>
38
- /// A button click event that creates a stamp from a local image and adds the standard stamp to the toolbar.
39
- /// </summary>
40
- /// <param name="sender">The source of the event.</param>
41
- /// <param name="e">Event data associated with the click event.</param>
42
- private void addStamp_Click ( object sender , RoutedEventArgs e )
43
- {
44
- // Clear the existing standard stamps if it is not needed.
45
- pdfViewer . ToolbarSettings . StampAnnotations . Clear ( ) ;
46
- //Load the custom image from the local disk.
47
- System . Windows . Controls . Image image = new System . Windows . Controls . Image ( ) ;
48
- image . Source = new BitmapImage ( new Uri ( System . IO . Path . Combine ( path , "Adventure_Cycle.jpg" ) , UriKind . RelativeOrAbsolute ) ) ;
49
- //Create a new standard stamp from the image.
50
- PdfStampAnnotation newStandardStamp = new PdfStampAnnotation ( image ) ;
51
- //Add the custom stamp in the toolbar.
52
- pdfViewer . ToolbarSettings . StampAnnotations . Add ( newStandardStamp ) ;
53
- }
38
+
39
+ /// <summary>
40
+ /// Document loaded event that handles the creation of stamps from the local images and adds the standard stamps to the toolbar.
41
+ /// </summary>
42
+ /// <param name="sender">Source of the event</param>
43
+ /// <param name="args">Event arguments</param>
44
+ private void PdfViewer_DocumentLoaded ( object sender , EventArgs args )
45
+ {
46
+ // Clear the existing standard stamps if it is not needed.
47
+ pdfViewer . ToolbarSettings . StampAnnotations . Clear ( ) ;
48
+ //Load the custom image from the local disk.
49
+ System . Windows . Controls . Image image1 = new System . Windows . Controls . Image ( ) ;
50
+ image1 . Source = new BitmapImage ( new Uri ( System . IO . Path . Combine ( path , "Adventure_Cycle.jpg" ) , UriKind . RelativeOrAbsolute ) ) ;
51
+ System . Windows . Controls . Image image2 = new System . Windows . Controls . Image ( ) ;
52
+ image2 . Source = new BitmapImage ( new Uri ( System . IO . Path . Combine ( path , "Confidential.png" ) , UriKind . RelativeOrAbsolute ) ) ;
53
+ //Create a new standard stamp from the image.
54
+ PdfStampAnnotation newStandardStamp1 = new PdfStampAnnotation ( image1 ) ;
55
+ PdfStampAnnotation newStandardStamp2 = new PdfStampAnnotation ( image2 ) ;
56
+ //Add the custom stamp in the toolbar.
57
+ pdfViewer . ToolbarSettings . StampAnnotations . Add ( newStandardStamp1 ) ;
58
+ pdfViewer . ToolbarSettings . StampAnnotations . Add ( newStandardStamp2 ) ;
59
+ }
54
60
}
55
61
}
0 commit comments