System gets slower when animating an annotation.

33 views
Skip to first unread message

Ryan

unread,
Apr 18, 2016, 8:16:41 PM4/18/16
to PDFTron PDFNet SDK
Question:

I am doing an animation, and every 2 seconds I call the following code

mMarkup= new Annot.Ink(CurrentAnno);
mMarkup.SetOpacity(value);
mMarkup.RefreshAppearance();

However, it appears to be not releasing memory over time. I am using PDFViewWPF.

Answer:

Yes, when you call methods like those, then some resources are being allocated, that won't be released, whether they are used or not, until PDFDoc.Save is called.

It would be best to do that sort of rendering on your own graphical layer over top of ours. In particular you can call PDFViewWPF.GetCanvas to get a canvas you can use for drawing.

At the very least reusing an existing Ink annot would be ideal, instead of calling new each time.

Ryan

unread,
Apr 19, 2016, 5:30:09 PM4/19/16
to pdfne...@googlegroups.com
Additional information. There are essentially two ways to "animate" an annotation.

#1
If you want to modify the appearance of the annotation while viewing, you need to: 
  1. Write lock the document. 
  2. get existing annotation. 
  3. create a new appearance and set it on the annotation. 
  4. tell the viewer to update the annotation rectangle. 
  5. release the lock.

#2 
The other alternative, is to add your annotation as normal. And then during viewing, 
  1. Read lock the document
  2. translate the annotation page coordinates to canvas coordinates
  3. using the PDFViewWPF.GetCanvas canvas, draw your own animation over top, so the actual annotation is not visible
  4. release read lock (no need to get PDFViewWPF to render anything) 
 

Reply all
Reply to author
Forward
0 new messages