<!-- Add a button to open OZR-->
<input type="button" value="OpenOZR" onclick="openForm('ozr')" >
// Add a function to open OZR by the button OpenOZR
function openForm(type){
if (type == "ozr") {
var url = "forcs/john.kim/customer.ozr";
var param = "connection.reportname=" + url + "; ";
}
param += "connection.servlet=/training/server; ";
param += "viewer.pagedisplay=singlepagecontinuous; ";
param += "viewer.viewmode=fittoframe; ";
param += "eform.signpad_type=dialog; ";
param += "comment.all=true; ";
param += "comment.selectedpen=highlightpen; ";
OZViewer.CreateReportEx(param, ";");
}
Open OZD
Create a folder named EXPORT under the webapps folder.
Get OZD from the viewer.
Save it to the EXPORT and repository_files.
<!-- Add a button to open OZD -->
<input type="button" value="OpenOZD" onclick="openForm('ozd')" >
// Add lines to open OZD
function openForm(type){
if (type == "ozr") {
var url = "forcs/john.kim/customer.ozr";
var param = "connection.reportname=" + url + "; ";
} else if (type == "ozd") {
//var url = "ozp://forcs/john.kim/customer.ozd";
var url = "http://localhost:8080/EXPORT/customer.ozd";
var param = "connection.openfile=" + url + "; ";
}
Close Viewer
<!-- Add a button to close OZR/OZD -->
<input type="button" value="Close" onclick="closeForm()" >
// Add a function to close OZR/OZDS
function closeForm() {
OZViewer.Script("close"); // The last viewer will be closed first
//OZViewer.Script("closeall"); // Remove all open viewer
}
Client-Side Exporting with MemoryStream
Side
Action
Client
ScriptEx("save_memorystream") converts the form as a memory stream in the specified format (OZD or PDF) and raises the event OZExportMemoryStreamCallBack.
ExportMemoryStreamCallBack_OZViewer(outputdata) triggered by OZExportMemoryStreamCallBack event receives the memory stream encoded in base64 with outputdata argument.
Sends the memory stream to the server application in the function OZExportMemoryStreamCallBack_OZViewer
Server
Receives the memory stream, decodes it, and saves it as a file in the target format.
Sends the target file path to the client.
Client
streamCallback receives the target file path.
<!-- Add a button and form -->
<input type="button" value="ExportStream" onclick="exportStream()" >
<form id="form">
<input type="hidden" id="fileName" name="fileName">
<input type="hidden" id="targetFormat" name="targetFormat">
<input type="hidden" id="stream" name="stream">
</form>
// Add JavaScript
var fileName = "customer.ozr"; // or ozd
var targetFormat = "ozd"; // or pdf
function exportStream() {
var param = "export.format=" + targetFormat;
param += "; export.path=C:\\TEMP;"
param += "; export.filename=temp";
param += "; export.mode=silent";
param += "; export.confirmsave=false";
param += "; ozd.allowreplaceformparam=true";
param += "; pdf.savecomment=true";
OZViewer.ScriptEx("save_memorystream", param,";");
}
function OZExportMemoryStreamCallBack_OZViewer(outputdata) {
if(outputdata == "{}") {
alert("Export failed.");
}else {
var obj = eval('(' + outputdata + ')');
var value = null;
for(var key in obj) value = obj[key];
$('#fileName').val(fileName);
$('#targetFormat').val(targetFormat);
$('#stream').val(value);
var param = $('form').serialize();
$.ajax({
type : "POST",
url : "./save-stream.jsp",
data : param,
async : false,
success : streamCallback,
error : function(request, status, error) {
if (request.status != '0') {
alert("code : " + request.status + "\r\nmessage : " + request.reponseText + "\r\nerror : " + error);
}
}
});
}
}
var streamCallback = function(path){
alert(path);
};