/** * @param $paragraph * @param $mainStyleSheet */ function __construct($paragraph, $mainStyleSheet) { if (java_instanceof($paragraph, java('org.apache.poi.xwpf.usermodel.XWPFParagraph'))) { $this->paragraph = $paragraph; } $this->mainStyleSheet = $mainStyleSheet; }
public static function autoFitTableToWindow($dataDir) { //ExStart //ExFor:Table.AutoFit //ExFor:AutoFitBehavior //ExId:FitTableToPageWidth //ExSummary:Autofits a table to fit the page width. // Open the document $doc = new java("com.aspose.words.Document", $dataDir . "TestFile.doc"); $nodeType = java("com.aspose.words.NodeType"); $table = $doc->getChild($nodeType->TABLE, 0, true); // Autofit the first table to the page width. $autoFitBehavior = new Java("com.aspose.words.AutoFitBehavior"); $table->autoFit($autoFitBehavior->AUTO_FIT_TO_WINDOW); // Save the document to disk. $doc->save($dataDir . "TestFile.AutoFitToWindow Out.doc"); //ExEnd $preferredWidthType = new Java("com.aspose.words.PreferredWidthType"); if (java_values($doc->getFirstSection()->getBody()->getTables()->get(0)->getPreferredWidth()->getType()) == java_values($preferredWidthType->PERCENT)) { echo "PreferredWidth type is not percent <br />"; } if (java_values($doc->getFirstSection()->getBody()->getTables()->get(0)->getPreferredWidth()->getValue()) == 100) { echo "PreferredWidth value is different than 100 <br />"; } }
public static function main() { echo "<pre>"; self::printTime("initializing..."); self::clearDir(self::$NEO4J_DB, false); self::$neo = new java("org.neo4j.kernel.EmbeddedGraphDatabase", self::$NEO4J_DB); self::$neo->shutdown(); self::printTime("clean db created"); self::$inserter = new java("org.neo4j.kernel.impl.batchinsert.BatchInserterImpl", self::$NEO4J_DB); self::createChildren(self::$inserter->getReferenceNode(), 10, 1); self::$inserter->shutdown(); self::printTime("nodes created"); self::$neo = new java("org.neo4j.kernel.EmbeddedGraphDatabase", self::$NEO4J_DB); for ($i = 0; $i < 10; $i++) { echo "\ntraversing through all nodes and counting depthSum..."; $tx = self::$neo->beginTx(); $traverser = self::$neo->getReferenceNode()->traverse(java('org.neo4j.graphdb.Traverser$Order')->BREADTH_FIRST, java('org.neo4j.graphdb.StopEvaluator')->END_OF_GRAPH, java('org.neo4j.graphdb.ReturnableEvaluator')->ALL_BUT_START_NODE, java('org.neo4j.graphdb.DynamicRelationshipType')->withName('PARENT'), java('org.neo4j.graphdb.Direction')->OUTGOING); $depthSum = 0; $nodes = $traverser->iterator(); while (java_values($nodes->hasNext())) { $node = $nodes->next(); $depthSum += intval(java_values($node->getProperty("level"))); } $tx->finish(); $tx->success(); echo "\ndepthSum = {$depthSum}"; self::printTime("done traversing"); } self::$neo->shutdown(); echo "\nneo has been shut down"; echo "</pre>"; }
/** * @param $run * @param $mainStyleSheet */ function __construct($run, $mainStyleSheet) { if (java_instanceof($run, java('org.apache.poi.xwpf.usermodel.XWPFRun'))) { $this->run = $run; } $this->mainStyleSheet = $mainStyleSheet; }
public function MBeanServer($id = null) { if (isset($id)) { $this->delegate = java("com.caucho.quercus.lib.resin.MBeanServer", $id); } else { $this->delegate = java("com.caucho.quercus.lib.resin.MBeanServer"); } }
/** * @param $picture * @param $mainStyleSheet * @param $path */ function __construct($picture, $mainStyleSheet, $path) { if (java_instanceof($picture, java('org.apache.poi.xwpf.usermodel.XWPFPicture'))) { $this->picture = $picture; } $this->mainStyleSheet = $mainStyleSheet; $this->_tmp_path = $path; }
/** * @param $element */ function __construct($element) { if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFSDT'))) { $toc = java_cast($element, 'org.apache.poi.xwpf.usermodel.XWPFSDT'); $this->toc = $toc; $this->idList = array(); $this->tableContents = array(); } }
function __construct($style) { if (java_instanceof($style, java('org.apache.poi.xwpf.usermodel.XWPFStyle'))) { $this->style = $style; } else { echo "This is not Style Class"; die; } }
function __construct($cell, $mainStyleSheet) { if (java_instanceof($cell, java('org.apache.poi.xwpf.usermodel.XWPFTableCell'))) { $this->cell = $cell; } else { throw new Exception("[XWPFTableCell::new XWPFTableCell] Cell cannot be null"); } $this->mainStyleSheet = $mainStyleSheet; $this->xmlCell = $this->getXMLCellObject(); }
/** create a temporary directory for the lucene index files. Make sure * to create the tmpdir from Java so that the directory has * javabridge_tmp_t Security Enhanced Linux permission. Note that PHP * does not have access to tempfiles with java_bridge_tmp_t: PHP * inherits the rights from the HTTPD, usually httpd_tmp_t. */ function create_index_dir() { global $tmp_file, $tmp_dir; $javaTmpdir = java("java.lang.System")->getProperty("java.io.tmpdir"); $tmpdir = java_values($javaTmpdir); $tmp_file = tempnam($tmpdir, "idx"); $tmp_dir = new java("java.io.File", "{$tmp_file}.d"); $tmp_dir->mkdir(); return java_values($tmp_dir->toString()); }
function init() { $SWT = new JavaClass("org.eclipse.swt.SWT"); $shell = $this->shell = new java("org.eclipse.swt.widgets.Shell"); $shell->setSize(320, 200); $shell->setLayout(new java("org.eclipse.swt.layout.FillLayout")); $button = new Java("org.eclipse.swt.widgets.Button", $this->shell, $SWT->PUSH); $button->setText("Click here."); $button->addSelectionListener(java_closure($this, null, java("org.eclipse.swt.events.SelectionListener"))); $this->shell->open(); }
function java_PageContext($java_session) { if (java_is_null($java_session)) { throw new Exception("session is null"); } $ctx = java_context(); $this->servlet = $ctx->getAttribute("php.java.servlet.Servlet"); $this->response = $ctx->getAttribute("php.java.servlet.HttpServletResponse"); $this->request = $ctx->getAttribute("php.java.servlet.HttpServletRequest"); $factory = java("javax.servlet.jsp.JspFactory")->getDefaultFactory(); $this->pc = $factory->getPageContext($this->servlet, $this->request, $this->response, null, true, 8192, false); $this->out = $this->pc->out; }
function run() { $name = java_values(java_context()->getAttribute("name", 100)); // engine scope $out = new Java("java.io.FileOutputStream", "{$name}.out", true); $Thread = java("java.lang.Thread"); $nr = java_values(java_context()->getAttribute("nr", 100)); echo "started thread: {$nr}\n"; for ($i = 0; $i < 10; $i++) { $out->write(ord("{$nr}")); $Thread->yield(); } $out->close(); }
function createComponents() { $button = new java("javax.swing.JButton", "I'm a Swing button!"); // set the label before we close over $this $this->label = new java("javax.swing.JLabel"); $button->addActionListener(java_closure($this, null, java("java.awt.event.ActionListener"))); $this->label->setLabelFor($button); $pane = new java("javax.swing.JPanel", new java("java.awt.GridLayout", 0, 1)); $pane->add($button); $pane->add($this->label); $BorderFactory = new JavaClass("javax.swing.BorderFactory"); $pane->setBorder($BorderFactory->createEmptyBorder(30, 30, 10, 30)); return $pane; }
public function renderReport($reportName, $options = [], $outputType = self::OUTPUT_TYPE_HTML) { $reportPath = ArrayHelper::getValue($options, 'reportPath', $this->reportPath); if ($reportPath === null) { throw new InvalidConfigException('The "reportPath" property must be set.'); } $reportPath = Yii::getAlias($reportPath); $context = java_context()->getServletContext(); $birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($context); java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook()); $report = $birtReportEngine->openReportDesign("{$reportPath}/{$reportName}"); // $parameterArray = $report->getDesignHandle()->getParameters(); // $ds = $report->getDesignHandle()->findDataSource("Data Source"); // $ds->setProperty('odaURL', 'jdbc:postgresql://localhost:5432/mdmbiz3'); $task = $birtReportEngine->createRunAndRenderTask($report); if (!empty($options['params'])) { foreach ($options['params'] as $key => $value) { $nval = new Java("java.lang.String", $value); $task->setParameterValue($key, $nval); } } if ($outputType == self::OUTPUT_TYPE_PDF) { $outputOptions = ['pdfRenderOption.pageOverflow' => 'pdfRenderOption.fitToPage']; } else { $outputOptions = []; } if (!empty($options['options'])) { $outputOptions = array_merge($outputOptions, $options['options']); } $optionClass = isset($this->optionClasses[$outputType]) ? $this->optionClasses[$outputType] : $this->optionClasses['default']; $taskOptions = new Java($optionClass); $outputStream = new Java("java.io.ByteArrayOutputStream"); $taskOptions->setOutputStream($outputStream); foreach ($outputOptions as $key => $value) { $taskOptions->setOption($key, $value); } $taskOptions->setOutputFormat($outputType); if ($outputType == self::OUTPUT_TYPE_HTML) { $ih = new Java("org.eclipse.birt.report.engine.api.HTMLServerImageHandler"); $taskOptions->setImageHandler($ih); $taskOptions->setEnableAgentStyleEngine(true); $taskOptions->setBaseImageURL($this->imagePath); $taskOptions->setImageDirectory($this->imagePath); } $task->setRenderOption($taskOptions); $task->run(); $task->close(); return java_values($outputStream->toByteArray()); }
public function __construct() { $this->_gateway = java_context()->getServletContext()->getAttribute(PetroQuick_Neo4JGateway_Config::GATEWAY_CONTEXT_PARAM); $this->_neo = $this->_gateway->getGraphDb(); $this->_index = $this->_gateway->factoryIndex(); $this->_fulltextIndex = $this->_gateway->factoryFulltextIndex(); $this->DIRECTION = java('org.neo4j.graphdb.Direction'); if (empty($this->_subrefNodeName)) { $parts = explode('_', get_class($this)); $this->_subrefNodeName = strtoupper($parts[count($parts) - 1]) . 'S'; } if (empty($this->_nodeName)) { $parts = explode('_', get_class($this)); $this->_nodeName = strtoupper($parts[count($parts) - 1]); } }
public static function deleteRowByBookmark($doc, $bookmarkName) { // Find the bookmark in the document. Exit if cannot find it. $bookmark = $doc->getRange()->getBookmarks()->get($bookmarkName); //echo java_values($bookmark); exit; if (java_values($bookmark) == null) { return; } // Get the parent row of the bookmark. Exit if the bookmark is not in a row. $row = $bookmark->getBookmarkStart()->getAncestor(java('com.aspose.words.Row')); //echo java_inspect($row); exit; if (java_values($row) == null) { return; } // Remove the row. $row->remove(); }
function showform() { $webname = $_SERVER["PHP_SELF"]; $username = getvardata("username", ""); $password = getvardata("password", ""); $errormsg = getvardata("errormsg", ""); java(); echo "<form name='mlogin' id='mlogin' action=\"{$webname}\" method='POST'>\n"; echo "<input type=hidden name=nextact id=nextact value=\"{$nextact}\">\n"; echo "<input type=hidden name=errmsg id=errmsg value=\"{$errormsg}\">\n"; echo "\t\t\tUsername? <input type=text name=username id=username value=\"{$username}\" size=10\">\n"; echo "\t\t\tPassword? <input type=password name=password id=password value=\"{$password}\" size=10>\n"; echo "\t\t\t<hr/>\n"; echo "\t\t\t<a href=\"#\" onclick=\"setnext('login');\">\"Login\"</a> \n"; echo "\t\t\t<a href='../../mobile.php'>\"Quit\"</a>\n"; echo "</form>\n"; if (strlen($errmsg) > 0) { echo "<hr>\n"; echo $errormsg; } setfocus("username"); }
function createDocument($jndiname, $serverArgs) { // find initial context $initial = new java("javax.naming.InitialContext", $serverArgs); try { // find the service $objref = $initial->lookup("{$jndiname}"); // access the home interface $home = java("javax.rmi.PortableRemoteObject")->narrow($objref, java("DocumentHome")); if (java_is_null($home)) { throw new Exception("home"); } // create a new remote document and return it $doc = $home->create(); } catch (JavaException $ex) { $cause = $ex->getCause(); echo "Could not create remote document. Have you deployed documentBean.jar?<br>\n"; echo "{$cause} <br>\nin file: {$ex->getFile()}<br>\nline:{$ex->getLine()}\n"; exit(1); } return $doc; }
public static function main() { $dataDir = "/usr/local/apache-tomcat-8.0.22/webapps/JavaBridge/Aspose_Words_Java_For_PHP/src/programmingwithdocuments/workingwithbookmarks/copybookmarkedtext/data/"; // Load the source document. $srcDoc = new Java("com.aspose.words.Document", $dataDir . "Template.doc"); // This is the bookmark whose content we want to copy. $srcBookmark = $srcDoc->getRange()->getBookmarks()->get("ntf010145060"); // We will be adding to this document. $dstDoc = new Java("com.aspose.words.Document"); // Let's say we will be appending to the end of the body of the last section. $dstNode = $dstDoc->getLastSection()->getBody(); // It is a good idea to use this import context object because multiple nodes are being imported. // If you import multiple times without a single context, it will result in many styles created. $importFormatMode = java('com.aspose.words.ImportFormatMode'); $importer = new Java("com.aspose.words.NodeImporter", $srcDoc, $dstDoc, $importFormatMode->KEEP_SOURCE_FORMATTING); // Do it once. CopyBookmarkedText::appendBookmarkedText($importer, $srcBookmark, $dstNode); // Do it one more time for fun. CopyBookmarkedText::appendBookmarkedText($importer, $srcBookmark, $dstNode); // Save the finished document. $dstDoc->save($dataDir . "Template Out.doc"); }
<?php require_once "java/Java.inc"; java_require("itext.jar"); try { $document = new java("com.lowagie.text.Document"); $out = new java("java.io.ByteArrayOutputStream"); $pdfWriter = java("com.lowagie.text.pdf.PdfWriter")->getInstance($document, $out); $document->open(); $font = java("com.lowagie.text.FontFactory")->getFont(java("com.lowagie.text.FontFactory")->HELVETICA, 24, java("com.lowagie.text.Font")->BOLDITALIC, new java("java.awt.Color", 0, 0, 255)); $paragraph = new java("com.lowagie.text.Paragraph", "Hello World", $font); $document->add($paragraph); $document->close(); $pdfWriter->close(); // print the generated document header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=HelloWorld.pdf"); echo java_values($out->toByteArray()); } catch (JavaException $e) { echo "Exception occured: "; echo $e; echo "<br>\n"; }
#!/usr/bin/php <?php include_once "java/Java.inc"; function x1($s1, $o1) { echo "c1: {$s1}, {$o1}\n"; return 1; } function c2($b) { return !java_values($b); } $here = realpath(dirname($_SERVER["SCRIPT_FILENAME"])); if (!$here) { $here = getcwd(); } java_require("{$here}/../tests.php5/callback.jar"); $closure = java_closure(null, array("c1" => "x1"), java("Callback")); $callbackTest = new java('Callback$Test', $closure); if ($callbackTest->test()) { echo "test okay\n"; exit(0); } else { echo "test failed\n"; exit(1); }
<?php include_once "java/Java.inc"; $here = getcwd(); try { java_require("{$here}/testCoerceArray.jar"); $t1 = new java("TestCoerceArray"); $t2 = new java("TestCoerceArray"); echo java("TestCoerceArray")->f(array($t1, $t2)); echo "\n"; } catch (Exception $e) { echo "test failed\n"; exit(1); } exit(0);
<?php include_once "java/Java.inc"; $here = getcwd(); java_require("{$here}"); class cg { function toString() { return "cg"; } } class TestClosure { function f() { return new java("java.lang.String", "hello"); } } class TestClosure1 { function g() { return new cg(); } } $c1 = java_closure(new TestClosure(), null, java("TestClosure")); echo $c1->f(); $c1 = java_closure(new TestClosure1(), null, java("TestClosure1")); echo $c1->g();
<?php require_once "java/Java.inc"; echo java("java.lang.System")->getProperties();
<?php require_once "http://localhost:8080/JavaBridge/java/Java.inc"; $System = java("java.lang.System"); echo $System->getProperties(); ?>
<?php header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=downloaded.pdf"); define("JAVA_HOSTS", "127.0.0.1:8080"); define("JAVA_SERVLET", "/JavaBridge/JavaBridge.phpjavabridge"); require_once "java/Java.inc"; session_start(); $here = getcwd(); $ctx = java_context()->getServletContext(); $birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx); java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook()); try { $report = $birtReportEngine->openReportDesign("{$here}/TopNPercent.rptdesign"); $task = $birtReportEngine->createRunAndRenderTask($report); $taskOptions = new java("org.eclipse.birt.report.engine.api.PDFRenderOption"); $outputStream = new java("java.io.ByteArrayOutputStream"); $taskOptions->setOutputStream($outputStream); $taskOptions->setOption("pdfRenderOption.pageOverflow", "pdfRenderOption.fitToPage"); $taskOptions->setOutputFormat("pdf"); $task->setRenderOption($taskOptions); $task->run(); $task->close(); } catch (JavaException $e) { echo $e; //"Error Calling BIRT"; } //echo $outputStream; echo java_values($outputStream->toByteArray());
echo $val ? $val : "Off"; ?> </td> <td>Ignore a local <code>WEB-INF/cgi/php-cgi-ARCH-OS</code> executable from the web archive and use the specified <code>php_exec</code>. Default is Off.</td> </tr> <tr> <td>php_include_java</td> <td><?php $val = java_values($context->getInitParameter("php_include_java")); echo $val ? $val : "Off"; ?> </td> <td>Shall the server add <code><?php include_once("java/Java.inc");?></code> at the top of each PHP script? Default is Off.</td> </tr> </table> </p> <?php /* current sevlet is PhpCGIServlet */ } ?> The settings were taken from the <a href="file://<?php echo java_values(java('php.java.servlet.ServletUtil')->getRealPath($context, '/WEB-INF/web.xml')); ?> ">WEB-INF/web.xml</a>. </body> </html>
// Second param "false" => we re-use the pre-created session without destroying the previous one // third param "0" => it nevers timeout. $SconesSession = java_session($config_ini["gate"]["sessionName"], false, 0); // Make sure the scones session is not already opened if (is_null(java_values($SconesSession->get("initialized")))) { /** * NOTE, SOMETIMES WHEN WE RUN SOMETHING FOR THE FIRST TIME, THE BRIDGE/TOMCAT CAN'T RESOLVE SOME * PATHS. WE HAVE TO CREATE SUCH A DUMMY OBJECT "ONCE" (? huhu) AND HE WILL FIND IT IN THE FUTURE... * I HAVE NO IDEA OF WHAT CAUSE THIS ISSUE, IF IT IS RELATED TO GATE ONLY OR NOT. */ $test = new java('gate.creole.ontology.OConstants$OntologyFormat'); // The session is not yet initialized. $SconesSession->put("initialized", FALSE); // The number of sessions that have been created for this Scones instance $SconesSession->put("nbSessions", $config_ini["gate"]["nbSessions"]); $Gate = java("gate.Gate"); $PersistenceManager = java("gate.util.persistence.PersistenceManager"); // Initialize GATE $Gate->init(); for ($i = 1; $i <= $config_ini["gate"]["nbSessions"]; $i++) { // Load the corpus pipeline from the application (XGAPP) file. $corpusController = $PersistenceManager->loadObjectFromFile(new java("java.io.File", $config_ini["gate"]["applicationFile"])); // Initialize and save sessions $SconesSession->put("session" . $i . "_used", FALSE); $SconesSession->put("session" . $i . "_instance", $corpusController); } $SconesSession->put("initialized", TRUE); echo "Initialized..."; } else { echo "Scones threads are already created. Destroy them first before running this script (using destroy.php)..."; }
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); $xlsExporter->setParameter($JRXlsExporterParameter->OUTPUT_FILE, new java("java.io.File", $out)); $xlsExporter->setParameter($JRXlsExporterParameter->IS_DETECT_CELL_TYPE, true); $xlsExporter->setParameter($JRXlsExporterParameter->IS_IGNORE_GRAPHICS, true); // $xlsExporter->setParameter($JRXlsExporterParameter->IS_WHITE_PAGE_BACKGROUND, true); $xlsExporter->exportReport(); } header("Content-type: " . $contentType); readfile($out); // unlink($out); } catch (Exception $ex) { echo "<b>Error...:</b>" . $ex->getCause(); } echo "done"; }