1. Project Background
When developing a document management system or an OA office system, it is easier to realize the function of processing word documents online, but there are often customers who ask for document version management, which requires opening two word files online at the same time and comparing two different versions. The content of the word document, almost no solution can be found on the Internet.
2. Solutions
Integrate PageOffice to process word files online, and call the function of comparing two word documents of PageOffice to solve this problem, and the calling method is very simple:
Java code behind:
PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(request); poCtrl1.setServerPage(request.getContextPath()+"/poserver.zz"); // Create custom toolbar poCtrl1.addCustomToolButton("保存", "SaveDocument()", 1); poCtrl1.addCustomToolButton("Show A document", "ShowFile1View()", 0); poCtrl1.addCustomToolButton("Show B document", "ShowFile2View()", 0); poCtrl1.addCustomToolButton("Show comparison result", "ShowCompareView()", 0); poCtrl1.setSaveFilePage("/SaveFile"); poCtrl1.wordCompare("doc/A.doc", "doc/B.doc", OpenModeType.docAdmin, "username");//Key code, open two word documents at the same time for comparison
Html page js:
<script language="javascript" type="text/javascript"> function SaveDocument() { document.getElementById("PageOfficeCtrl1").WebSave(); } function ShowFile1View() { document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = false; document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 1; } function ShowFile2View() { document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = false; document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 0; } function ShowCompareView() { document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = true; document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 0; } function SetFullScreen () { document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen; } </script>
The code to display PageOffice in the Html code:
<div style="width:1000px; height:800px;"> <%=poCtrl1.getHtmlCode("PageOfficeCtrl1")%> </div>
File comparison effect: display the content of document A
File comparison effect: display the content of document B
File comparison effect: display the comparison result