问题
I have a PDFTron webviewer which I use to render a pdf form. I need to extract the form xml from the webviewer when user click on external save button.
I tried
var am = readerControl.docViewer.getAnnotationManager();
var xfdfString = am.exportAnnotations();
$.ajax({
type: 'POST',
url: readerControl.serverUrl + '?did=' + readerControl.docId,
data: xfdfString,
success: function(data) {
// Annotations were successfully uploaded to server
},
error: function(jqXHR, textStatus, errorThrown) {
console.warn("Failed to send annotations to server. " + textStatus);
},
dataType: 'xml'
});
But I cannot get hold of readerControl
outside the PDFTron config.js
.
Please help
回答1:
config.js is the preferred place for webviewer modifications because it executes in the context of the viewer's iframe window. More on this in the following tutorial:
https://www.pdftron.com/webviewer/demo/tutorials/getting-started-config-files.html
Alternatively you could access iframe variables through contentWindow
as described in the following post: https://stackoverflow.com/a/13758233/1710586
来源:https://stackoverflow.com/questions/37320786/how-to-get-form-data-from-pdftron-webviewer