怎么将SAPDocumentBuilder的word控件设置成只读模式-创新互联

这篇文章将为大家详细讲解有关怎么将SAP Document Builder的word控件设置成只读模式,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

站在用户的角度思考问题,与客户深入沟通,找到汪清网站设计与汪清网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名注册、网页空间、企业邮箱。业务覆盖汪清地区。

最近我正在从事一个客户项目,客户的一个要求是他们不希望word文档在word控件中可编辑。

这意味着工具栏中的所有按钮和菜单都应该被禁用。

怎么将SAP Document Builder的word控件设置成只读模式

image

The first idea comes to my mind is the flag “enableReadWrite“.

怎么将SAP Document Builder的word控件设置成只读模式

image

As documented in  sap help,it can fulfill my help but unfortunately it is deprecated. Regardless of this warning I have a try and found it does not work indeed.

怎么将SAP Document Builder的word控件设置成只读模式

然后我推测,如果上传的文档是只读的,那么工具栏肯定会被禁用。因此,问题变成了如何在上传过程中将文档标记为只读。

自word 2007以来,MS office的格式遵循所谓的“Open office”协议,其规范可在此处找到。

如果将文件类型扩展名从更改为。docx到。使用WinRAR压缩并打开它,您会发现该文档实际上是由多个单个文件组成的包(在SAP internal中称为文档部分)。可编辑性由文件设置控制。xml。

怎么将SAP Document Builder的word控件设置成只读模式

如果你不知道确切的语法,就用谷歌搜索。我在谷歌的解释中使用了:

现在任务非常简单,只需在文档源代码中添加必要的xml标记即可。您不需要手动解析文档源代码,因为SAP已经完成了这项工作。您可以重用标准类CL_DOCX_文档。

由于我需要在“设置”节点中插入文档保护节点,因此为此编写了一个简单的转换。魔术在第18行和第21行之间。


  
  
  
    
      
    
  
  
    
      
        
      
      
        readOnly
        1
      
      
    
  

and find a proper place to call the transformation:

 DATA: lr_element   TYPE REF TO if_wd_context_element,
         lv_file_data TYPE xstring,
         lv_ret       TYPE i,
         lx_temp      TYPE xstring,
         lv_msg       TYPE string,
         lt_parms     TYPE /ipro/tt_key_value_pair,
         ls_parm      LIKE LINE OF lt_parms.
   lr_element = me->wd_context->get_element( ).
   CHECK lr_element IS NOT INITIAL.
   lr_element->get_attribute( EXPORTING name = 'BINARY' IMPORTING value = lv_file_data ).
   DATA(lo_docx) = cl_docx_document=>load_document( lv_file_data  ).
   DATA(lo_main_part) = lo_docx->get_maindocumentpart( ).
   DATA(lo_docx_settings) = lo_main_part->get_documentsettingspart( ).
   DATA(lx_settings) = lo_docx_settings->get_data( ).
   /ipro/cl_docx_utilities=>transform( EXPORTING  iv_input_xstring    = lx_settings
                                   iv_transform_name  = '/IPRO/DOCXCC_PROTECT'
                                   it_parameters      = lt_parms
                        IMPORTING  ev_result          = lx_temp
                                   ev_ret             = lv_ret
                                   ev_message         = lv_msg  ).
   lo_docx_settings->feed_data( lx_temp ).
   DATA(lx_docx_package) = lo_docx->get_package_data( ).
   lr_element->set_attribute( EXPORTING name = 'BINARY'  value = lx_docx_package ).

after that the tag will be there in settings.xml:

怎么将SAP Document Builder的word控件设置成只读模式

image

The word control before upload document looks like below, buttons and menus available:

怎么将SAP Document Builder的word控件设置成只读模式

image

After upload, menu and button are disabled. If you try to edit the document, there will be notifications in the right pane to give you a hint that is not possible.

怎么将SAP Document Builder的word控件设置成只读模式

当然,此解决方案不适用于较低版本的MS word,如word2003。幸运的是,我的客户有足够的钱,他们已经在使用Office 2013,所以我不必为此担心。

关于怎么将SAP Document Builder的word控件设置成只读模式就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


当前文章:怎么将SAPDocumentBuilder的word控件设置成只读模式-创新互联
文章链接:http://lszwz.com/article/gpjpe.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款