Best Practics to hide all annots in WPF viewer

49 views
Skip to first unread message

Daniel Lutz

unread,
Apr 17, 2014, 10:13:05 AM4/17/14
to pdfne...@googlegroups.com
Hello support,

i have a question about the posibilites to hide all annotation from the pdfdoc in the wpf viewer. In the moment i have a derivate class which implement to async methods.

Task HideAllAnnotations()
       {
           return Task.Run(() =>
               {
                   var pageCount = GetPageCount();
                   for (var i = 1; i <= pageCount; i++)
                   {
                       var page = GetPage(i);
                       var annotCount = page.GetNumAnnots();
                       for (var j = 0; j < annotCount; j++)
                       {
                           var annot = page.GetAnnot(j);
                           if (!annot.IsValid() || annot.GetFlag(Annot.Flag.e_hidden)) continue;
                           annot.SetFlag(Annot.Flag.e_hidden, true);
                           _hiddenAnnots.Add(annot);
                       }
                   }
               });
       }

and

Task ShowAllAnnotations()
       {
           return Task.Run(() =>
               {
                   foreach (var annot in _hiddenAnnots)
                   {
                       if (annot.IsValid())
                           annot.SetFlag(Annot.Flag.e_hidden, false);
                   }
               });
       }

I_hiddenAnnots is a List<Annot> object. Before i set the open document to the viewer i call HideAnnots and  in a override Dispose methode i use ShowAllAnnotation to change the changes back. Is there any way to implement a best way in the viewer (bool property IsAnnotsVisible or a method ShowAnnots()/HideAnnots()) without a hack the document class? The Problem is when i call annot.SetFlag(...) and close the document without call Save() all annots are invisible! So i write a recall method to set all annots  visible! Maybe it is a bug? So what are the best practicse to hide alle document annots in the wpf viewer withput block the gui thread?

Thanks 
Daniel

Tomas Hofmann

unread,
Apr 21, 2014, 12:46:31 PM4/21/14
to pdfne...@googlegroups.com
Hi Daniel,

It sounds to me that what you are looking for is PDFViewWPF.SetDrawAnnotations(bool render_annots).
Please let us know if this is not the case.

Best Regards,
Tomas Hofmann
Reply all
Reply to author
Forward
0 new messages