java to open PDF documents online

Step 1: (tools involved)

  Visit: http://www.zhuozhengsoft.com/dowm/, download PageOffice for Java from the official website.

Step 2: (Configuration Project)

  1. Unzip the PageOffice development package, open the "Integration Files" directory, and copy pageoffice4.4.0.2.jar in the "WEB-INF\lib" directory to the "WEB-INF\lib" directory of your own project

  2. Refer to the web.xml file in the "integration files" folder to configure the web.xml file in your web project, or you can directly add the following configuration to your web.xml;

copy code

1     <!-- PageOffice Begin -->
 2     <servlet>
 3         <servlet-name>poserver</servlet-name>
 4         <servlet-class>com.zhuozhengsoft.pageoffice.poserver.Server</servlet-class>
 5     </servlet>
 6     <servlet-mapping>
 7         <servlet-name>poserver</servlet-name>
 8         <url-pattern>/poserver.zz</url-pattern>
 9     </servlet-mapping>
10     <servlet-mapping>
11         <servlet-name>poserver</servlet-name>
12         <url-pattern>/sealsetup.exe</url-pattern>
13     </servlet-mapping>
14     <servlet-mapping>
15         <servlet-name>poserver</servlet-name>
16         <url-pattern>/posetup.exe</url-pattern>
17     </servlet-mapping>
18     <servlet-mapping>
19         <servlet-name>poserver</servlet-name>
20         <url-pattern>/pageoffice.js</url-pattern>
21     </servlet-mapping>
22     <servlet-mapping>
23         <servlet-name>poserver</servlet-name>
24         <url-pattern>/jquery.min.js</url-pattern>
25     </servlet-mapping>
26     <servlet-mapping>
27         <servlet-name>poserver</servlet-name>
28         <url-pattern>/pobstyle.css</url-pattern>
29     </servlet-mapping>
30     <!-- PageOffice End-->

copy code

  3. Add a reference to the pageoffice.js file and a hyperlink to open the file "Open PDF Online" on the page that displays the file list (for example: doclist.jsp):

copy code

<script type="text/javascript" src=" jquery.min.js"></script>
<script type="text/javascript" src=" pageoffice.js" id="po_js_main"></script>
......
<a href="javascript:POBrowser.openWindowModeless(/pdf.jsp','width=1200px;height=800px;');">在线打开PDF</a>

copy code

  4. Add the import package on the page calling PageOffice products (eg: pdf.jsp): com.zhuozhengsoft.pageoffice.*

  5. Write the calling code of PageOffice and open the file online (for example: test.pdf in the root directory of the server D drive):

PDFCtrl poCtrl1 = new PDFCtrl(request);
poCtrl1.setServerPage(request.getContextPath()+"/poserver.zz");
poCtrl1.webOpen("d:\\test.pdf");

  6. Insert the following code in the body of the html code where the office interface needs to appear:

<%=poCtrl1.getHtmlCode("PDFCtrl1")%>

  7. Start the running project, visit the page of the file list (for example: doclist.jsp), and click the hyperlink of "Open PDF Online" to view the effect of opening, editing, and saving PDF files online.

Reference example:

  1. Deploy the PageOffice example: Copy the Samples4 folder in the PageOffice development kit to the Webapps directory of Tomcat, and visit: http://localhost:8080/Samples4/index.html
  2. Refer to the basic function example: 2.4. Open online PDF file

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326338690&siteId=291194637