Page tree
Skip to end of metadata
Go to start of metadata

List of examples

Type

Descriptions

JAVA

An example of using API with the JDK

JSP

An example of using API in jsp

Javascript - window.open()

An example of activating the viewer on a new window.

Javascript - AJAX (POST)

An example of performing conversion in the AJAX way using the POST method.

Javascript - AJAX (GET)

An example of performing conversion in the AJAX way using the GET method.

JAVA

An example of using API with the JDK

Java Example
@RequestMapping("/preview")
public ModelAndView convertTest(HttpServletRequest request,
        @RequestParam(value = "fid", required = true) String fid,
        @RequestParam(value = "filePath", required = true) String filePath,
        @RequestParam(value = "convertType", required = false, defaultValue = "0") String convertType,
        @RequestParam(value = "fileType", required = false, defaultValue = "URL") String fileType) {
    try {
        String encodedUrl = URLEncoder.encode(filePath, "UTF-8");
        String requestUrl = "{Server Address}/SynapDocViewServer/job?fid=" + fid // Server Address Setting
									+ "&filePath=" + encodedUrl + "&convertType=" + convertType 
									+ "&fileType=" + fileType;
         
        ModelAndView mav = new ModelAndView("redirect:" + requestUrl);
        return mav;
    }
    catch(UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}

JSP 

An example of using API in jsp

Java Example
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.net.URLEncoder"%>
<%

String fid = request.getParameter("fid");
String filePath = request.getParameter("filePath");
 
String converType = "0"; 
String fileType = "URL"; 
String encodedUrl = URLEncoder.encode(filePath, "UTF-8");
 
String requestUrl = "{Server Address}/SynapDocViewServer/job?fid=" + fid // Server Address Setting
							+ "&filePath=" + encodedUrl + "&convertType=" + convertType 
							+ "&fileType=" + fileType;

response.sendRedirect(requestUrl);
%>

Javascript

window.open()

An example of activating the viewer on a new window.

javascript Example - 1
function preview(fid, filePath) { // fid : File ID, filePath : File Download URL
	// Convert to HTML
	var convertType = "0";
	// Download document via URL and convert
	var fileType = "URL";
	
	var encodedUrl = encodeURIComponent(filePath);
	var requestUrl = "{Server Address}/SynapDocViewServer/job?fid=" + fid // Server Address Setting
							+ "&filePath=" + encodedUrl + "&convertType=" + convertType 
							+ "&fileType=" + fileType;
	
	window.open(requestUrl, "preview");
}

AJAX.post()

An example of performing conversion in the AJAX way using the POST method.

javascript Example - 1
function preview(fid, filePath) { // fid : File ID, filePath : File Download URL
	var convertType = "0";

	var fileType = "URL";
	var encodedUrl = encodeURIComponent(filePath);
	var requestUrl = "{Server Address}/SynapDocViewServer/job?fid=" + fid // Server Address Setting
							+ "&filePath=" + encodedUrl
							+ "&convertType=" + convertType + "&fileType=" + fileType; 
	window.open(requestUrl, "preview");
}

AJAX.get()

An example of performing conversion in the AJAX way using the GET method.

javascript Example - 1
var filePath = "#########"; // File Download URL
filePath = encodeURI(filePath);
var fid = "SAMPLE001";
$.ajax({
    type: "GET",
    url: "{Server Address}/SynapDocViewServer/job", // Server Address Setting
    data: {	
				"fileType": "URL", "convertType": "0", 
				"filePath": filePath, "downloadUrl": "", 
				"fid":fid, "sync": false, 
				"force": false, "urlEncoding": "UTF-8"
			},
    contentType: "application/json;charset=utf-8",
    dataType: 'json',
    async: false,
    cache: false,
    success: function (data) {
        alert(data);
    },
    error: function (error) {
        alert(error.status + " : " + error.statusText);
    }
});
  • No labels