【问题标题】:Read Only Form Filling - PDFTron只读表格填写 - PDFTron
【发布时间】:2019-02-25 08:17:28
【问题描述】:

我正在使用 PDFTron 的 WebViewer [1] 在 Web [2] 上的 PDF 中填写表单字段。有一种方法可以使某些字段处于只读模式,因此用户将无法向文本字段添加文本,请选中复选框?

我在文档 [3] 上找到了此页面,但似乎我只能将文档设置为只读模式,而我只想要只读的自定义字段,用户将能够填写某些字段而不能填写其他字段。 我还在 doc 上找到了此页面 [4] 以将字段设置为只读,但在我的情况下,在 WebViewer 上它不起作用,在我的浏览器中,viewerLoaded 事件永远不会被调用;我试图将代码放在代码的另一部分,但没有任何反应。

你们有一些提示或一些工作代码吗?
谢谢,阿尔贝托

[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

【问题讨论】:

  • 很好,但是您能否将答案移至实际答案。这是 StackOverflow 中的首选方式(您可以回答自己的问题)。谢谢!

标签: pdftron


【解决方案1】:

我设法使它与此代码的修改版本一起工作 [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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-10
    • 1970-01-01
    • 2023-03-16
    • 2015-03-04
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多