How to prevent ink annotations from shifting slightly after you save them

49 views
Skip to first unread message

Tomas Hofmann

unread,
Dec 8, 2014, 3:18:05 PM12/8/14
to pdfne...@googlegroups.com
Q: When I create an ink annotation using mouse or finger, then when I am done, the annotation shifts slightly as it is being saved to the document. This does not happen with the pen. Is there a way to prevent this from happening for mouse and touch as well.

A: This happens because when the ink in completed and is being pushed back into the PDFDoc, calling RefreshAppearance will apply smoothing to the ink to make it look better. When using stylus, we have found that the ink looks very good even without smoothing, and in fact smoothing can sometimes make ink annotations drawn with a stylus look worse, since the stylus is so accurate to begin with. We found that with touch or mouse, the ink annotations usually don't look as good, and so we do apply smoothing.
The smoothing algorithm in the SDK is fairly advanced, and so we use simpler smoothing in the Tools. This is causing the discrepancy in appearance you see when the ink is finished.

In order to get rid of this, you need to disable smoothing both on the UI (i.e. in the FreeHandCreate tool) and in the pushed back ink.
To disable it for the UI, it's as simple as editing AddPointToPath so that the boolean smooth defaults to false.
To edit the way the SDK displays the ink when RefreshAppearance is called, find the following snipped inside Finish():
if (mIsStylus)
{
    ink.SetSmoothing(false);
}
and simply remove the if statement so that it always happens.

Ryan

unread,
Aug 10, 2016, 8:55:26 PM8/10/16
to PDFTron PDFNet SDK
Currently for our WPF viewer, which doesn't have SetSmoothing function, you can use the following code.


if (mIsStylus)
{
 
Obj* mk_dict = mp_obj->FindObj("MK");
 
if (!mk_dict || !mk_dict->IsDict())
 
{
 mk_dict
= mp_obj->PutDict("MK");
 
}
 mk_dict
->PutBool("__smooth_with_bezier_curve", use_smoothing);
}

Reply all
Reply to author
Forward
0 new messages