我正在使用PDFTron中的WebViewer [1]来填写Web上的PDF格式[2]。有一种方法可以在只读模式下创建一些字段,因此用户将无法在文本字段中添加文本,请选中复选框?
我在文档[3]上找到了这个页面,但似乎我只能在只读模式下设置文档,而我只想要只读自定义字段,用户将能够填充某些字段而不是其他字段。 我在doc上找到了这个页面[4],将字段设置为readonly,但在我的情况下,在WebViewer上它不起作用,在我的浏览器中,viewerLoaded事件永远不会被调用;我试图将代码放在代码的另一部分但没有任何反应。
你们使用的是否有一些提示或一些工作代码? 谢谢,Alberto [1] https://www.pdftron.com/webviewer [2] https://www.pdftron.com/pdf-sdk/form-filler [3] https://www.pdftron.com/documentation/web/guides/annotations/annotation-permissions?searchTerm=readon#readonly-mode [4] https://www.pdftron.com/documentation/web/guides/advanced/forms#set-fields-to-readonly
我设法使用此代码的修改版本[1]。最终结果是:
$(document).on('documentLoaded', function() {
var docViewer = myWebViewer.getInstance().docViewer;
var annotManager = docViewer.getAnnotationManager();
annotManager.on('annotationChanged', function(e, annotations, action) {
// if the annotation change occurs because of an import then
// these are fields from inside the document
if (action === 'add' && e.imported) {
annotations.forEach(function(annot) {
if(annot.fieldName == 'read_only_field_name'){
annot.fieldFlags.set('ReadOnly', true);
}
});
}
});
});
[1] https://www.pdftron.com/documentation/web/guides/advanced/forms#set-fields-to-readonly