Exemple #1
0
 public function __construct()
 {
     $this->ip = C('APP_IP');
     require_once "http://" . $this->ip . ":8080/JavaBridge/java/Java.inc";
     //此行必须
     java_set_file_encoding("UTF-8");
     //设置中文编码,若涉及到中文必须设置中文编码
     $this->PageOfficeCtrl = new Java("com.zhuozhengsoft.pageoffice.PageOfficeCtrlPHP");
     //此行必须
     $this->PDFCtrl = new Java("com.zhuozhengsoft.pageoffice.PDFCtrlPHP");
     //此行必须
     $this->OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
     $this->PageOfficeLink = new JavaClass("com.zhuozhengsoft.pageoffice.PageOfficeLink");
 }
<?php 
$ip = $_SERVER['SERVER_NAME'];
//获取本机IP
require_once "http://" . $ip . ":8080/JavaBridge/java/Java.inc";
//此行必须
$fs = new Java("com.zhuozhengsoft.pageoffice.FileSaverPHP");
//此行必须
$fs->load(file_get_contents("php://input"));
//此行必须
java_set_file_encoding("GBK");
//设置编码格式
//获取通过Url传递过来的值
$id = 0;
$id = $_REQUEST["id"];
$filepath = dirname($_SERVER["SCRIPT_FILENAME"]);
$fs->saveToFile($filepath . "/page/" . $id . "/" . $fs->getFileName());
//保存文件
echo $fs->close();
//此行必须
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'SaveFile.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
    </head>

    <body bgcolor = "#FFFFFF" text = "#000000">
        <?php
            //define("JAVA_DEBUG", true); //调试设置
            define("JAVA_RECV_SIZE", 8192);

            //define("JAVA_HOSTS", "127.0.0.1:8080"); //设置javabridge监听端口,如果开启javabridge.jar设置的端口不是8080,可通过此语句更改
            require_once("java/Java.inc"); //php调用java的接口,必须的
            $here=realpath(dirname($_SERVER["SCRIPT_FILENAME"]));

            if (!$here)
                $here=getcwd();

            java_set_library_path("$here/lib");                            //设置java开发包位置
            java_set_file_encoding("GBK");                                 //设置java编码

            $client=new java("com.bocom.netpay.b2cAPI.BOCOMB2CClient");
            $ret=$client->initialize("C:/bocommjava/ini/B2CMerchant.xml"); //初始化配置文件
						$ret = java_values($ret);
            if ($ret != "0")
                {
                $err=$client->getLastErr();
                //为正确显示中文对返回java变量进行转换,如果用java_set_file_encoding进行过转换则不用再次转换
                //$err = java_values($err->getBytes("GBK")); 
                $err=java_values($err);
                print "初始化失败,错误信息:" . $err . "<br>";
                exit(1);
                }

            $rep=$client->queryAccountBalance();
Exemple #4
0
 $root = realpath(".");
 $in = $root . "\\well_test" . ($exportType == "Excel" ? "_excel" : "") . ".jrxml";
 $report = java("net.sf.jasperreports.engine.JasperCompileManager")->compileReport($in);
 $dateFormat = new java("java.text.SimpleDateFormat", "yy/MM/dd");
 $d = $dateFormat->parse($from_date);
 $params = new java("java.util.HashMap");
 $params->put("facility_id", intval($facility_id));
 // dây là 1 param
 $params->put("begin_date", new java("java.sql.Date", $d->getTime()));
 $params->put("report_time", $_REQUEST["report_time"]);
 $params->put("ROOT_DIR", $root);
 $print = java("net.sf.jasperreports.engine.JasperFillManager")->fillReport($report, $params, $connection);
 $contentType = "text/Html";
 $out = 'out.html';
 if ($exportType == "PDF") {
     java_set_file_encoding("ISO-8859-1");
     $contentType = "application/pdf";
     // export Pdf
     $out = $root . "/output.pdf";
     java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToPdfFile($print, $out);
 } elseif ($exportType == "HTML") {
     // export Pdf
     $out = $root . "/output.Html";
     $contentType = "text/Html";
     java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToHtmlFile($print, $out);
 } elseif ($exportType == "Excel") {
     $out = $root . "/output.xls";
     $contentType = "application/vnd.ms-excel";
     $xlsExporter = new java("net.sf.jasperreports.engine.export.JRXlsExporter");
     $JRXlsExporterParameter = java("net.sf.jasperreports.engine.export.JRXlsExporterParameter");
     $xlsExporter->setParameter($JRXlsExporterParameter->JASPER_PRINT, $print);
Exemple #5
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
// Start server with:
// java -Dfile.encoding=ASCII -jar JavaBridge.jar INET:0 4 ""
// test UTF8 and ISO-8859-1 input and convert output to UTF-8.
// WARNING: Open and save this file with a HEX editor only!
java_set_file_encoding("ASCII");
$string = new Java("java.lang.String", "Cześć! -- שלו� -- Grüß Gott -- Dobrý deň -- Dobrý den -- �ん���, コ�ニ�ハ", "UTF-8");
print java_values($string->getBytes("UTF-8")) . "\n";
$string = new Java("java.lang.String", "Grüß Gott", "ISO-8859-1");
print java_values($string->getBytes("UTF-8")) . "\n";
function java_set_encoding($enc)
{
    return java_set_file_encoding($enc);
}
Exemple #7
0
 function saveOnlineEditWord()
 {
     // 		$ip = GetHostByName($_SERVER['SERVER_NAME']);//获取本机IP
     $ip = C("DB_HOST_WORD");
     //"192.168.0.238";
     require_once "http://{$ip}:8088/JavaBridge/java/Java.inc";
     //此行必须
     $fs = new Java("com.zhuozhengsoft.pageoffice.FileSaverPHP");
     //此行必须
     echo $fs->close();
     //此行必须
     $fs->load(file_get_contents("php://input"));
     //此行必须
     java_set_file_encoding("utf8");
     //设置编码格式
     $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
     $file_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
     $fs->saveToFile($file_path);
     //保存文件
     echo $fs->close();
     //此行必须
 }
<?php

if (!defined('THINK_PATH')) {
    exit;
}
$ip = GetHostByName($_SERVER['SERVER_NAME']);
require_once "http://" . $ip . ":8080/JavaBridge/java/Java.inc";
$PageOfficeCtrl = new Java("com.zhuozhengsoft.pageoffice.PageOfficeCtrlPHP");
$PageOfficeCtrl->setServerPage("http://" . $ip . ":8080/JavaBridge/poserver.zz");
java_set_file_encoding("utf8");
$doc = new Java("com.zhuozhengsoft.pageoffice.wordwriter.WordDocument");
$dataRegion1 = $doc->openDataRegion("PO_question");
$dataRegion1->setEditing(true);
$dataRegion1->setValue("");
$dataRegion1->setSubmitAsFile(true);
$dataRegion2 = $doc->openDataRegion("PO_answer");
$dataRegion2->setEditing(true);
$dataRegion2->setValue("");
$dataRegion2->setSubmitAsFile(true);
$dataRegion3 = $doc->openDataRegion("PO_jiexi");
$dataRegion3->setEditing(true);
$dataRegion3->setValue("");
$dataRegion3->setSubmitAsFile(true);
$PageOfficeCtrl->setWriter($doc);
$PageOfficeCtrl->addCustomToolButton("uTeach编题区", "Save", 9);
$PageOfficeCtrl->setSaveDataPage("/Word/SaveData.php?id=" . $_SESSION['uid']);
$PageOfficeCtrl->setMenubar(false);
$PageOfficeCtrl->setTitlebar(false);
$PageOfficeCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
$OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
$PageOfficeCtrl->webOpen($questionDocPath, $OpenMode->docSubmitForm, "张三");
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$file_encoding = "ASCII";
java_set_file_encoding($file_encoding);
$out = new java("java.io.ByteArrayOutputStream");
$stream = new java("java.io.PrintStream", $out);
$str = new java("java.lang.String", "Cześć! -- שלום -- Grüß Gott", "UTF-8");
$stream->print($str);
echo "Stream: " . $out->__toString() . "\n";
echo "Stream as {$file_encoding} string: " . java_values($out->toString()) . "\n";
echo "Stream as binary data: " . java_cast($out->toByteArray(), "S") . "\n";