java implementation of online editing and flow of word documents

Keywords: JSP Java SQLite JQuery

Using pageoffice to realize document online editing and document flow

1: process

Draft documents in the modified traceless mode, open them in the forced trace mode when leaders annotate their opinions, open them in the approval mode when the clerk cleans up the draft, and open the released official documents in the final read-only mode. Among them, the handwriting function provided by PageOffice is also demonstrated in the leader's annotation link, and the seal can be affixed after the document is approved.

2: Detailed code

<!-- PageOffice Begin -->
	<servlet>
		<servlet-name>poserver</servlet-name>
		<servlet-class>com.zhuozhengsoft.pageoffice.poserver.Server</servlet-class>
	</servlet>

	
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/poserver.zz</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/sealsetup.exe</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/posetup.exe</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/pageoffice.js</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/jquery.min.js</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>poserver</servlet-name>
		<url-pattern>/pobstyle.css</url-pattern>
	</servlet-mapping>
	<servlet>
		<servlet-name>adminseal</servlet-name>
		<servlet-class>com.zhuozhengsoft.pageoffice.poserver.AdminSeal</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>adminseal</servlet-name>
		<url-pattern>/adminseal.zz</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>adminseal</servlet-name>
		<url-pattern>/loginseal.zz</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>adminseal</servlet-name>
		<url-pattern>/sealimage.zz</url-pattern>
	</servlet-mapping>
	<mime-mapping>
		<extension>mht</extension>
		<mime-type>message/rfc822</mime-type>
	</mime-mapping>
	<context-param>
		<param-name>adminseal-password</param-name>
		<param-value>111111</param-value>
	</context-param>
	<!-- PageOffice End -->
<a href="word.jsp?type=creat">Online editing</a> →
<a href="word.jsp?type=check&user=Zhang San">Zhang San marking </a> →
<a href="word.jsp?type=check&user=LiSi">Li Si marking</a> →
<a href="word.jsp?type=accept">Clerk</a> →
<a href="word.jsp?type=publish">Official dispatch</a>
<%@ page language="java"
	import="java.util.*,com.zhuozhengsoft.pageoffice.*,com.zhuozhengsoft.pageoffice.wordwriter.*"
	pageEncoding="UTF-8"%>
<%@page import="java.awt.Color"%>
<%
	String type = (String) request.getParameter("type");
	String user = (String) request.getParameter("user");

	PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
	//Set up server page
	poCtrl.setServerPage(request.getContextPath() + "/poserver.zz");
	//Add custom button
	poCtrl.addCustomToolButton("Preservation", "Save", 1);
	poCtrl.addCustomToolButton("Full screen/reduction", "IsFullScreen", 4);
	//Set save page
	poCtrl.setSaveFilePage("SaveFile.jsp");

	if ("creat".equals(type)) {
		//Open document in normal editing mode open Word document
		poCtrl.webOpen("doc/test.doc", OpenModeType.docNormalEdit,
				"Zhang Yi Ming");
	}
	if ("check".equals(type)) {
		poCtrl.addCustomToolButton("display/Hidden traces", "Show_HidRevisions", 5);
		poCtrl.addCustomToolButton("Leadership circle", "StartHandDraw", 3);
		poCtrl.addCustomToolButton("Insert keyboard comment", "StartRemark", 3);
		poCtrl.addCustomToolButton("Layered handwriting annotations", "ShowHandDrawDispBar",7);

		//Force trace mode open document open Word document
		poCtrl.webOpen("doc/test.doc", OpenModeType.docRevisionOnly,user);
	}
	if ("accept".equals(type)) {
		poCtrl.addCustomToolButton("display/Hidden traces", "Show_HidRevisions", 5);
		poCtrl.addCustomToolButton("Insert seal/autograph", "InsertSeal", 2);
		poCtrl.addCustomToolButton("Accept all changes", "AcceptAllRevisions", 5);
		poCtrl .addCustomToolButton("Layered handwriting annotations", "ShowHandDrawDispBar",7);
		//Review mode open document open Word document
		poCtrl.webOpen("doc/test.doc", OpenModeType.docAdmin, "Zhang Yi Ming");
	}
	if ("publish".equals(type)) {
		poCtrl.addCustomToolButton("Save locally", "ShowDialog(0)", 5);
		poCtrl.addCustomToolButton("Page setup", "ShowDialog(1)", 0);
		poCtrl.addCustomToolButton("Printing", "ShowDialog(2)", 6);

		poCtrl.setMenubar(false);
		poCtrl.setOfficeToolbars(false);
		//Read only mode open document open Word document
		poCtrl.webOpen("doc/test.doc", OpenModeType.docReadOnly, "Zhang Yi Ming");
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
	<script type="text/javascript">
		//Preservation
        function Save() {
            document.getElementById("PageOfficeCtrl1").WebSave();
        }
        
        //Full screen / restore
        function IsFullScreen() {
            document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;
        }
		//Show / hide traces
        function Show_HidRevisions() {
            document.getElementById("PageOfficeCtrl1").ShowRevisions = !document.getElementById("PageOfficeCtrl1").ShowRevisions;
        }
        
        //Leaders circle and sign
        function StartHandDraw() {
            document.getElementById("PageOfficeCtrl1").HandDraw.SetPenWidth(5);
            document.getElementById("PageOfficeCtrl1").HandDraw.Start();
        }
		// Insert keyboard comment
        function StartRemark() {
            var appObj = document.getElementById("PageOfficeCtrl1").WordInsertComment();

        }	
        //Layered handwriting annotations
        function ShowHandDrawDispBar() {
            document.getElementById("PageOfficeCtrl1").HandDraw.ShowLayerBar(); ;
        }


        //Accept all changes
        function AcceptAllRevisions() {
            document.getElementById("PageOfficeCtrl1").AcceptAllRevisions(); 
        }
        
        function ShowDialog(index) {
            if (index == 0) document.getElementById("PageOfficeCtrl1").ShowDialog(2);
            if (index == 1) document.getElementById("PageOfficeCtrl1").ShowDialog(5);
            if (index == 2) document.getElementById("PageOfficeCtrl1").ShowDialog(4);
        }
        
        //Insert seal
        function InsertSeal(){
        	try {
				document.getElementById("PageOfficeCtrl1").ZoomSeal.AddSeal();
			} catch(e) {}
        }
  
    </script>
	</head>
	<body>
		<div style="height: 850px; width: 1036px; overflow: hidden;">
			<%=poCtrl.getHtmlCode("PageOfficeCtrl1")%>
		</div>
	</body>
</html>

Save code

FileSaver fs=new FileSaver(request,response);
fs.saveToFile(request.getSession().getServletContext().getRealPath("doc/")+"/"+fs.getFileName());
fs.close();

3: Precautions

(1) This example demonstrates a simple file flow without returning. To return and re edit the review document, you can write your own logic

(2) The seal used in this example is a simple seal provided by pgaeoffice. sqlite database is used. sqlite jar and poseal.db files must be copied. You can go to http://www.zhuozhengsoft.com/dowm/ Download the trial program. There are corresponding files in it

Posted by Ferenc on Wed, 25 Dec 2019 12:10:17 -0800