I have done some more work on this. It seems that even isolating the PDFNet instance in an angular service still causes problems when trying to use the APIs in conjunction with a document instance within webviewer.
The workaround I have found so far is to just run the following in the webviewer config.js
(function () {
$(document).on('documentLoaded', function () {
PDFNet.initialize().then(function () {
parent.postMessage('PDFNetLoaded', '*');
});
});
})();
And within Angular listen for the PDFNetLoaded event and then grab the PDFNet instance from the webviewer iframe, eg.
window.addEventListener('message', function (e) {
if (e.data === 'PDFNetLoaded') {
var PDFNet = this.viewerIframe.contentWindow.PDFNet;
}
}, false);
This seems to work, and this PDFNet instance then seems to play perfectly nicely with the doc instance in webviewer.
It seems like a slight hack though, so if anybody has any better ideas about how to set this up, or if you can see any major gotchas with this approach, let me know.
Glen