如何將SAP Document Builder的word控制元件設定成只讀模式
Recently I am working on a customer project and one customer requirement is they do not want to the word document be editable in the word control.
That means all buttons and menus in toolbar should be disabled.
The first idea comes to my mind is the flag “enableReadWrite“.
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.
Then I am speculating that if the document uploaded is read only, it is for sure that the toolbar will be disabled. So the issue turns to that how could I mark the document to be read only on the fly during uploading.
Since word 2007 the format of MS office follows the so called “Open office” protocol whose specification could be found
here.
If you change the file type extension from .docx to .zip and open it with WinRAR, you will find the document is actually a bundle of several single files ( called document part in SAP internal ). The editability is controlled within the file settings.xml.
If you don’t know the exact syntax, just google it. I use the explanation from this one in google:
Now the task is quite easy, just add the necessary xml tag into the document source code. You do not need to manually parse the document source code since SAP has already done this job. You can just reuse standard class CL_DOCX_DOCUMENT.
Since I need to insert the document protection node in “settings” node, a simple transformation is written for this. The magic is between line 18 and 21.
and find a proper place to call the transformation:
after that the tag will be there in settings.xml:
The word control before upload document looks like below, buttons and menus available:
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.
Of course this solution does not work for lower version of MS word like word2003. Fortunately my customer has enough money and they are already using Office 2013 so I do not need to worry about it.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2708659/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- word只讀文件怎麼改成可編輯文件 word檔案怎樣取消只讀模式模式
- SAP document builder一些常見問題的解答UI
- easyui datebox 設定只讀UI
- 如何將Word文件轉成Excel表格?Excel
- 設計模式:Builder模式概述設計模式UI
- 設定document物件的高度物件
- word檔案怎樣取消只讀模式 把只讀檔案轉化為可編輯檔案模式
- 文件被鎖定以只讀模式開啟怎麼取消 檔案只讀模式怎麼解除模式
- word相容模式怎樣換成正常模式 如何把word相容模式改成標準模式
- Java設計模式之builder模式Java設計模式UI
- 設計模式-建造者模式(Builder)設計模式UI
- word多級列表如何自動設定 word多級列表設定的步驟
- MySQL設定資料庫為只讀MySql資料庫
- word藝術字型如何設定?
- SAP Gateway Service Builder 裡的 OData Model 定義方式GatewayUI
- 設計模式--建造者模式(Builder Pattern)設計模式UI
- 【設計模式筆記】(二)- Builder模式設計模式筆記UI
- 設計模式-生成器模式Builder設計模式UI
- 【設計模式】- 生成器模式(Builder)設計模式UI
- word底紋怎麼設定 設定word底紋的方法
- word分欄怎麼設定 word設定分欄的方法
- 如何將檔案PDF格式轉換成Word格式
- 《設計模式》 - 3. 建立者模式( Builder )設計模式UI
- 設計模式(五)Builder構建者模式設計模式UI
- 直播網站程式原始碼,【openpyxl】只讀模式、只寫模式網站原始碼模式
- 如何將SAP WebClient UI的表格匯出成PDFWebclientUI
- Builder 模式UI模式
- word標題格式怎麼設定 word標題格式設定的方法
- 在word中怎麼設定目錄 word設定目錄的方法
- 將 SQL轉換成 Laravel Query Builder 程式碼SQLLaravelUI
- 設計模式十: 生成器模式(Builder Pattern)設計模式UI
- 重識設計模式-建造者模式(Builder Pattern)設計模式UI
- C#設計模式-建造者模式(Builder Pattern)C#設計模式UI
- Java 高效程式設計之 Builder 模式Java程式設計UI模式
- SAP雲平臺的Document Service
- 人人都會設計模式: 07、建造者模式--Builder設計模式UI
- python word 應用,設定 word 文件的內容格式Python
- IDEA如何設定成Eclipse的快捷鍵IdeaEclipse