How to get form data from pdftron webviewer

谁都会走 提交于 2019-12-11 01:07:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!