I'm trying to add a custom annotation on a PDF in a WPF application but OnCustomAnnotationPaint event never occurs so nothing gets drawn. I modified the sample application "Csharp-Annotations.WPF" to show this problem:
Code: Select all
private void OpenFileCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
CloseDocument();
GdViewer1.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer;
GdPictureStatus status = GdViewer1.DisplayFromFile("");
if (status == GdPictureStatus.OK)
{
GdViewer1.Focus();
//ThumbnailEx1.LoadFromGdViewer(GdViewer1);
ShowPageCount();
[b] var annoManager = GdViewer1.GetAnnotationManager();
var custom = annoManager.AddCustomAnnot(1, 1, 1, 1, 1);
annoManager.OnCustomAnnotationPaint += AnnoManager_OnCustomAnnotationPaint;[/b]
}
else
{
System.Windows.MessageBox.Show("Can not open file. Status: " + status.ToString());
}
}
private void AnnoManager_OnCustomAnnotationPaint(GdPicture14.Annotations.AnnotationCustom Annot, System.Drawing.Graphics g)
{
g.DrawRectangle(System.Drawing.Pens.Red, new System.Drawing.Rectangle(0, 0, 10, 10));
}
https://imgur.com/a/SlJNfNf
Is there something wrong in the way I'm using AddCustomAnnot or is it broken?