Problems creating multiple Annotations programmatically on mobile

39 views
Skip to first unread message

sbi

unread,
Jul 20, 2017, 5:20:57 AM7/20/17
to pdfnet-w...@googlegroups.com
Hi,

we implemented a full page search feature in our WebViewer custom config.
It finds a search word in the full text of the page and gets the quads of these occurances.
After that it creates an annotation for every occurance and uses the TextHighlightCreateTool to draw them onto the page.

This works extremely well on the desktop version of the WebViewer but does not draw every annotation when doing the same on mobile.

As the culprit I have identified the use of the Underscore JS function "throttle" which wraps every call to the select Function of any TextTool on mobile.
This results in only drawing an annotation every 50 ms, every call inbetween is thrown away and no annotation is drawn.

The throttling occurs in MobileReaderControl.js line 196-199.

Is there a way to call the original select function of the TextTool directly without the throttling?

Thanks in advance

Justin Jung

unread,
Jul 20, 2017, 7:02:31 PM7/20/17
to PDFTron WebViewer on behalf of sbi
You can find the code below from MobileReaderControl.js and delete it:

var throttledSelect = _.throttle(window.Tools.TextTool.prototype.select, 50);
window.Tools.TextTool.prototype.select = function() {
    throttledSelect.apply(this, arguments);
};

Justin Jung
Software Developer
PDFTron Systems Inc.

sbi

unread,
Jul 21, 2017, 3:36:44 AM7/21/17
to PDFTron WebViewer
Thanks for the tipp.

I don't really see it as a viable option to alter the WebViewer Code like this as it pretty much destroys the upgradeability (we already have some "hacks" in there as no real solution was provided).
A startup option to disable mobile throttling would be perfect.

Justin Jung

unread,
Jul 21, 2017, 6:42:06 PM7/21/17
to PDFTron WebViewer on behalf of sbi
After some more thought, we realized you can actually add the following to config.js:

var originalTextSelect = window.Tools.TextTool.prototype.select;

$(document).on('viewerLoaded', function() {
  window.Tools.TextTool.prototype.select = originalTextSelect;
});
Reply all
Reply to author
Forward
0 new messages