Similarly how do I customize the annotation load/save popup with messages of my own. (e.g. missing XFDF file during GET, save errors during POST, etc.)?
To be able to handle errors from document load failures you can set a callback on the part retriever object in ReaderControl.js. Look for the loadDocument function and near the bottom, just before the line this.docViewer.LoadAsync(...) add the following:
partRetriever.SetErrorCallback(function(err) {
// show some error message
});This will be called if there is an error while initially loading the document or if there is an error while trying to download a part of the file. One thing to note is that for documents without any bookmarks this callback will be triggered for the DocStruct.struct file but this can be safely ignored.To customize the behavior with annotations you can look at the $.ajax call in onDocumentLoaded for loading annotations and the saveAnnotations function for saving annotations. There are success and error callbacks for the $.ajax calls and you can modify these as you like.Matt ParizeauSoftware DeveloperPDFTron Systems Inc.
$(document).on('viewerLoaded', function() {
var originalLoadDocument = readerControl.loadDocument;
readerControl.loadDocument = function(doc) {
if (myXMLTestingFunction(doc)) {
console.log("show error");
} else {
originalLoadDocument.apply(this, arguments);
}
};
});
partRetriever.setErrorCallback(function(err) {
// show some error message
});