예제 #1
0
//此行必须
$FileMakerCtrl->setServerPage("http://" . $ip . ":8080/JavaBridge/poserver.zz");
//此行必须,设置服务器页面
java_set_file_encoding("GBK");
//设置中文编码,若涉及到中文必须设置中文编码
$id = $_REQUEST["id"];
$filepath = "doc/" . $id . "/" . date('Ymd', time());
$type = $_REQUEST['type'];
$doc = new Java("com.zhuozhengsoft.pageoffice.wordwriter.WordDocument");
//声明WordDocument变量
$FileMakerCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
//禁用右击事件
$doc->setDisableWindowRightClick(true);
//给数据区域赋值,即把数据填充到模板中相应的位置
//$doc->openDataRegion("PO_company")->setValue("北京卓正志远软件有限公司");
$FileMakerCtrl->setSaveFilePage("SaveMaker.php?id=" . $id . "&type=" . $type);
$FileMakerCtrl->setWriter($doc);
$FileMakerCtrl->setJsFunction_OnProgressComplete("OnProgressComplete()");
$DocumentOpenType = new Java("com.zhuozhengsoft.pageoffice.DocumentOpenType");
$FileMakerCtrl->fillDocument($filepath . "/" . $type . ".doc", $DocumentOpenType->Word);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<title>My JSP 'FileMaker.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
예제 #2
0
 /**
  * @Title: playSWF
  * @Description: todo(文件在线查看方法)
  * @author liminggang
  * @date 2014-8-12 下午5:29:50
  * @throws
  */
 function playSWF()
 {
     $file_type = "file";
     $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
     $uid = $_REQUEST['uid'];
     $file_path = $resource_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
     $this->assign("resource_path", $resource_path);
     if (!file_exists($file_path)) {
         $this->display("Public:playswfno");
         exit;
     }
     $info = pathinfo($file_path);
     $filesArr = C('TRANSFORM_SWF');
     $filesArr[] = 'pdf';
     $photoArr = C('IMG_file');
     $file_extension_lower = strtolower($info['extension']);
     if ($file_extension_lower == "docx" || $file_extension_lower == "doc") {
         $action = $this->getActionName();
         // 			$ip = gethostbyname($_SERVER['SERVER_NAME']);
         $ip = C("DB_HOST_WORD");
         //"192.168.0.238";
         require_once "http://{$ip}:8088/JavaBridge/java/Java.inc";
         //此行必须
         $PageOfficeCtrl = new Java("com.zhuozhengsoft.pageoffice.PageOfficeCtrlPHP");
         //此行必须
         $PageOfficeCtrl->setServerPage("http://{$ip}:8088/JavaBridge/poserver.zz");
         //此行必须,设置服务器页面
         $url = __ROOT__ . "/Admin/index.php/{$action}/saveOnlineEditWord/name/" . $_REQUEST['name'];
         java_set_file_encoding("utf8");
         //设置中文编码,若涉及到中文必须设置中文编码
         // 			//添加自定义按钮
         // 			$PageOfficeCtrl->addCustomToolButton("保存","Save",1);
         // 			//设置保存页面
         $PageOfficeCtrl->setSaveFilePage($url);
         $PageOfficeCtrl->addCustomToolButton("保存", "Save", 1);
         $PageOfficeCtrl->addCustomToolButton("显示/隐藏修改记录", "Show_HidRevisions", 7);
         // 			$PageOfficeCtrl->setAllowCopy(false);//禁止拷贝
         //$PageOfficeCtrl->setMenubar(false);//隐藏菜单栏
         // 			$PageOfficeCtrl->setOfficeToolbars(false);//隐藏Office工具条
         // 			$PageOfficeCtrl->setCustomToolbar(false);//隐藏自定义工具栏
         //打开excel文档
         $PageOfficeCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
         //若使用谷歌浏览器此行代码必须有,其他浏览器此行代码可不加
         $OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
         $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
         $file_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "/Public/", $file_path);
         // 			$PageOfficeCtrl->webOpen($file_path, $OpenMode->docNormalEdit, "张三");//此行必须
         //获取用户名称
         $loginUserName = getFieldBy($uid, "id", "name", "user");
         $PageOfficeCtrl->webOpen($file_path, $OpenMode->docRevisionOnly, $loginUserName);
         //此行必须
         $this->assign('PageOfficeCtrl', $PageOfficeCtrl->getDocumentView("PageOfficeCtrl1"));
         $this->display("Public:showEditWord");
     } else {
         if (in_array($file_extension_lower, $filesArr)) {
             $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "../Public", $info["dirname"]);
             if ('pdf' == $file_extension_lower) {
                 $file_path .= '/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 import('@.ORG.OfficeOnline.OfficeOnlineView');
                 $OfficeOnlineView = new OfficeOnlineView();
                 if (!file_exists(str_replace("pdf", "swf", $file_path))) {
                     $OfficeOnlineView->pdf2swf($resource_path, str_replace("MisFileManagerPlaySWF", "MisFileManager", $info['dirname']), 1);
                 }
                 $result = 0;
             } else {
                 $result = 0;
                 $file_path .= '/pdf/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 if (!file_exists($file_path)) {
                     $result = 1;
                     //调用文件IO操作,生成文件
                     $HttpSoctetIOAction = A('Http');
                     $HttpSoctetIOAction->createPDF(str_replace("MisFileManager", "MisFileManagerPlaySWF", $info['dirname']), $resource_path);
                     $file_path = str_replace("MisFileManager", "MisFileManagerPlaySWF", $file_path);
                     $file_path = str_replace("pdf", "swf", $file_path);
                 }
             }
             $this->assign('result', $result);
             $this->assign('file_name', $_REQUEST['filename']);
         }
         if (in_array($file_extension_lower, $photoArr)) {
             $file_type = "photo";
         }
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "__PUBLIC__", $file_path);
         $this->assign("file_type", $file_type);
         $this->assign('file_path', str_replace("pdf", "swf", $file_path));
         $this->display("Public:playswf");
     }
 }