How to set FreeHand opacity for WPF?

Q: I’m using PDFViewWPF and want to set the opacity of Freehand annotations.


Everything you need for this is in PDFViewWPF tools.

The default opacity for shape annotations (freehand, rectangle, etc) is stored in pdftron.PDF.Tools.Properties.Settings.Default.MarkupOpacity
There is also built in user interface so users can adjust the opacity as they want.

However if you truly want to set it programatically then you just need to modify SimpleShapeCreate.mOpacity variable.


I am still having some problem to change the opacity of e_ink annotations. I refer to the code of SelectionHelper class, and find that it is “pdftron.PDF.Tools.Properties.
Settings.Default.MarkupOpacity = value” that change the opacity of e_Ink annotation, which will change the opacity of all annotations.

And then I try to change the opacity of the e_ink annotations like this:

var CurrentAnno = page.GetAnnot(i); mMarkup = new pdftron.PDF.Annots.Markup(CurrentAnno); mMarkup.SetOpacity(0.5); page.AnnotRemove(CurrentAnno); page.AnnotPushBack(mMarkup); _pdfviewWpf.Update(mMarkup,page.GetIndex());


When you are done making changes to the properties of the annotation, you should call mMarkup.RefreshAppearance().

So to change the opacity of a markup annotation the minimal code is the following.

wpfviewer.DocLock(); // write lock Page page = wpfviewer.GetDoc().GetPage(page_num); var CurrentAnno = page.GetAnnot(i); var mMarkup = new pdftron.PDF.Annots.Markup(CurrentAnno); mMarkup.SetOpacity(0.5); mMarkup.RefreshAppearance(); wpfviewer.DocUnlock(); wpfviewer.Update(mMarkup, page_num);