How to set FreeHand opacity for WPF?

26 views
Skip to first unread message

Ryan

unread,
Dec 24, 2015, 1:29:50 PM12/24/15
to PDFTron PDFNet SDK
Q: I'm using PDFViewWPF and want to set the opacity of Freehand annotations.

------------------------------------------------------------------------------------

A:

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.

Ryan

unread,
Jan 12, 2016, 12:26:46 PM1/12/16
to PDFTron PDFNet SDK
Q:

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


----------------------------------------------------------------------------------------------
A:

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



Reply all
Reply to author
Forward
0 new messages