AddCustomAnnot: OnCustomAnnotationPaint event not occurring

Discussions about annotation support.
Post Reply
jannera
Posts: 1
Joined: Thu Jul 18, 2019 2:52 pm

AddCustomAnnot: OnCustomAnnotationPaint event not occurring

Post by jannera » Thu Jul 18, 2019 3:00 pm

Hi

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));
        }

If I uncomment the ThumbnailEx1.LoadFromGdViewer row, then the event occurs but still nothing is drawn except on the thumbnail viewer. Here is an image of what happens:

Image
https://imgur.com/a/SlJNfNf

Is there something wrong in the way I'm using AddCustomAnnot or is it broken?

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: AddCustomAnnot: OnCustomAnnotationPaint event not occurring

Post by Gabriela » Thu Jul 18, 2019 4:06 pm

Hello,

Here is the thread that can be useful:
https://forums.gdpicture.com/viewtopic.php?f=28&t=4867
Kind regards,

Gabriela
GdPicture Team

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest