本文介绍了如何从pdftron Webviewer获取表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PDFTron Webviewer,可用于呈现pdf表单.当用户单击外部保存按钮时,我需要从webviewer中提取xml表单.

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.

我尝试过

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'
   });

但是我无法在PDFTron config.js之外获取readerControl.请帮助

But I cannot get hold of readerControl outside the PDFTron config.js.Please help

推荐答案

config.js是Webviewer修改的首选位置,因为它在查看器的iframe窗口的上下文中执行.在以下教程中对此有更多的了解:

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

或者,您也可以按照以下帖子中的说明通过contentWindow访问iframe变量: https://stackoverflow.com/a/13758233/1710586

Alternatively you could access iframe variables through contentWindow as described in the following post: https://stackoverflow.com/a/13758233/1710586

这篇关于如何从pdftron Webviewer获取表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 20:39