public static function run($dataDir = null) { # initialize barcode reader $img = $dataDir . "barcode.jpg"; $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # Try to recognize all possible barcodes in the image while (java_values($reader->read())) { # Display the symbology type print "BarCode Type: " . (string) $reader->getReadType() . PHP_EOL; # Display the codetext print "BarCode CodeText: " . (string) $reader->getCodeText() . PHP_EOL; # Get the barcode region $region = $reader->getRegion(); if ($region != null) { # Initialize an object of type BufferedImage to get the Graphics object $imageIO = new ImageIO(); // $file=new File(); $bufferedImage = $imageIO->read(new File($img)); # Initialize graphics object from the image $g = $bufferedImage->getGraphics(); $color = new Color(); # Initialize paint object $p = new GradientPaint(0, 0, $color->red, 100, 100, $color->pink, true); $region->drawBarCodeEdges($g, $color->RED); # Save the image $imageIO->write($bufferedImage, "png", new File($dataDir . "Code39StdOut.png")); } } # Close reader $reader->close(); }
public static function SplitDocumentToPages(File $docName) { $folderName = $docName->getParent(); $fileName = $docName->getName(); $extensionName = $fileName->substring($fileName->lastIndexOf(".")); $outFolder_obj = new File($folderName, "Out"); $outFolder = $outFolder_obj->getAbsolutePath(); echo "<BR> Processing document: " . $fileName . $extensionName; $doc = new Document($docName->getAbsolutePath()); // Create and attach collector to the document before page layout is built. $layoutCollector = new LayoutCollector(doc); // This will build layout model and collect necessary information. $doc->updatePageLayout(); // Split nodes in the document into separate pages. $splitter = new DocumentPageSplitter($layoutCollector); // Save each page to the disk as a separate document. for ($page = 1; $page <= java_values($doc->getPageCount()); $page++) { $pageDoc = $splitter->GetDocumentOfPage($page); $file_obj = new File($outFolder, MessageFormat::format("{0} - page{1} Out{2}", $fileName, $page, $extensionName)); $abs_path = $file_obj->getAbsolutePath(); $pageDoc->save($abs_path); } // Detach the collector from the document. $layoutCollector->setDocument(null); }
public static function run($dataDir = null) { $img = $dataDir . "barcode.jpg"; # initialize barcode reader $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # Call read method $reader->read(); # Now get all possible barcodes $barcodes = $reader->getAllPossibleBarCodes(); $i = 0; while (java_values($i < strlen($barcodes))) { # Display code text, symbology, detected angle, recognition percentage of the barcode print "Code Text: " . (string) $barcodes[$i]->getCodetext() . " Symbology: " . (string) $barcodes[$i]->getBarCodeReadType() . " Recognition percentage: " . (string) $barcodes[$i]->getAngle() . PHP_EOL; # Display x and y coordinates of barcode detected $point = $barcodes[$i]->getRegion()->getPoints(); print "Top left coordinates: X = " . (string) $point[0]->getX() . ", Y = " . (string) $point[0]->getY() . PHP_EOL; print "Bottom left coordinates: X = " . (string) $point[1]->getX() . ", Y = " . (string) $point[1]->getY() . PHP_EOL; print "Bottom right coordinates: X = " . (string) $point[2]->getX() . ", Y = " . (string) $point[2]->getY() . PHP_EOL; print "Top right coordinates: X = " . (string) $point[3]->getX() . ", Y = " . (string) $point[3]->getY() . PHP_EOL; break; } # Close reader $reader->close(); }
public static function removeComments() { $args = func_get_args(); $doc = $args[0]; if (isset($args[1]) && !empty($args[1])) { $authorName = $args[1]; } // Collect all comments in the document $nodeType = Java("com.aspose.words.NodeType"); $comments = $doc->getChildNodes($nodeType->COMMENT, true); $comments_count = $comments->getCount(); // Look through all comments and remove those written by the authorName author. $i = $comments_count; $i = $i - 1; while ($i >= 0) { $comment = $comments->get($i); //echo "<PRE>"; echo java_inspect($comment); exit; if (isset($authorName)) { if (java_values($comment->getAuthor()->equals($authorName))) { $comment->remove(); } } else { $comment->remove(); } $i--; } }
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>"; }
/** * Copies content of the bookmark and adds it to the end of the specified node. * The destination node can be in a different document. * * @param importer Maintains the import context. * @param srcBookmark The input bookmark. * @param dstNode Must be a node that can contain paragraphs (such as a Story). */ private static function appendBookmarkedText($importer, $srcBookmark, $dstNode) { $startPara = $srcBookmark->getBookmarkStart()->getParentNode(); // This is the paragraph that contains the end of the bookmark. $endPara = $srcBookmark->getBookmarkEnd()->getParentNode(); if (java_values($startPara) == null || java_values($endPara) == null) { throw new Exception("Parent of the bookmark start or end is not a paragraph, cannot handle this scenario yet."); } // Limit ourselves to a reasonably simple scenario. $spara = java_values($startPara->getParentNode()); $epara = java_values($endPara->getParentNode()); if (trim($spara) != trim($epara)) { throw new Exception("Start and end paragraphs have different parents, cannot handle this scenario yet."); } // We want to copy all paragraphs from the start paragraph up to (and including) the end paragraph, // therefore the node at which we stop is one after the end paragraph. $endNode = $endPara->getNextSibling(); // This is the loop to go through all paragraph-level nodes in the bookmark. $curNode = $startPara; $cNode = java_values($curNode); $eNode = java_values($endNode); //echo $cNode . "<BR>1" . $eNode; exit; while (trim($cNode) != trim($eNode)) { // This creates a copy of the current node and imports it (makes it valid) in the context // of the destination document. Importing means adjusting styles and list identifiers correctly. $newNode = $importer->importNode(java_values($curNode), true); $curNode = $curNode->getNextSibling(); $cNode = java_values($curNode); $dstNode->appendChild(java_values($newNode)); } }
public function getCell($pos) { $cell = java_values($this->row->getCell($pos)); if (is_object($cell)) { return $cell; } else { return null; } }
/** 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 _send_response($bridge) { $page_data = $bridge->getResponseData(); $page_data = java_values($page_data); // @ apache_setenv('no-gzip', 1); // @ ini_set('zlib.output_compression', 0); header("Content-type: " . $this->props->getProperty("content")); header("Content-Length: " . strlen($page_data)); echo $page_data; }
public static function run($dataDir = null) { $pres = new Presentation(); # Get the first slide $sld = $pres->getSlides()->get_Item(0); # Define columns with widths and rows with heights $dbl_cols = [50, 50, 50]; $dbl_rows = [50, 30, 30, 30]; # Add table shape to slide $tbl = $sld->getShapes()->addTable(100, 50, $dbl_cols, $dbl_rows); $fill_type = new FillType(); $color = new Color(); # Set border format for each cell $row = 0; while ($row < java_values($tbl->getRows()->size())) { $cell = 0; while ($cell < $tbl->getRows()->get_Item($row)->size()) { $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->setWidth(5); $cell += 1; } $row += 1; } $tbl->getColumns()->get_Item(0)->get_Item(0)->getTextFrame()->setText("00"); $tbl->getColumns()->get_Item(0)->get_Item(1)->getTextFrame()->setText("01"); $tbl->getColumns()->get_Item(0)->get_Item(2)->getTextFrame()->setText("02"); $tbl->getColumns()->get_Item(0)->get_Item(3)->getTextFrame()->setText("03"); $tbl->getColumns()->get_Item(1)->get_Item(0)->getTextFrame()->setText("10"); $tbl->getColumns()->get_Item(2)->get_Item(0)->getTextFrame()->setText("20"); $tbl->getColumns()->get_Item(1)->get_Item(1)->getTextFrame()->setText("11"); $tbl->getColumns()->get_Item(2)->get_Item(1)->getTextFrame()->setText("21"); # AddClone adds a row in the end of the table $tbl->getRows()->addClone($tbl->getRows()->get_Item(0), false); # AddClone adds a column in the end of the table $tbl->getColumns()->addClone($tbl->getColumns()->get_Item(0), false); # InsertClone adds a row at specific position in a table $tbl->getRows()->insertClone(2, $tbl->getRows()->get_Item(0), false); # InsertClone adds a row at specific position in a table $tbl->getColumns()->insertClone(2, $tbl->getColumns()->get_Item(0), false); # Write the presentation as a PPTX file $save_format = new SaveFormat(); $pres->save($dataDir . "CloneRowColumn.pptx", $save_format->Pptx); print "Cloned Row & Column from table, please check the output file."; PHP_EOL; }
private function insertWatermarkIntoHeader($watermarkPara, $sect, $headerType) { $header = $sect->getHeadersFooters()->getByHeaderFooterType($headerType); if (java_values($header) == null) { // There is no header of the specified type in the current section, create it. $header = new Java("com.aspose.words.HeaderFooter", $sect->getDocument(), $headerType); $sect->getHeadersFooters()->add($header); } // Insert a clone of the watermark into the header. $header->appendChild($watermarkPara->deepClone(true)); }
public static function AppendDocs() { // The path to the documents directory. $dataDir = "/usr/local/apache-tomcat-8.0.22/webapps/JavaBridge/Aspose_Words_Java_For_PHP/src/quickstart/appenddocuments/data/"; // Load the destination and source documents from disk. $dstDocObject = new Java("com.aspose.words.Document", $dataDir . "TestFile.Destination.doc"); $srcDocObject = new Java("com.aspose.words.Document", $dataDir . "TestFile.Source.doc"); $importFormatModeObject = new java('com.aspose.words.ImportFormatMode'); $sourceFormating = $importFormatModeObject->KEEP_SOURCE_FORMATTING; // Append the source document to the destination document while keeping the original formatting of the source document. $dstDocObject->appendDocument(java_values($srcDocObject), java_values($sourceFormating)); $dstDocObject->save($dataDir . "TestFile_Out.docx"); }
/** * Tests whether the database is really empty after the _cleanupDb method. */ public function testCleanupDb() { $tx = $this->_neoGateway->factoryTransaction(); $nodes = $this->_neoGateway->getGraphDb()->getAllNodes()->iterator(); $nodesCount = 0; while (java_values($nodes->hasNext())) { $nodesCount++; $nodes->next(); } $tx->success(); $tx->finish(); $this->assertEquals($nodesCount, 1, 'Database is not empty or reference node had been removed.'); }
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(); }
public static function find_shape($slide, $alttext) { #Iterating through all shapes inside the slide $i = 0; $slide_size = java_values($slide->getShapes()->size()); while ($i < $slide_size) { # If the alternative text of the slide matches with the required one then return the shape if ($slide->getShapes()->get_Item($i)->getAlternativeText() == $alttext) { return $slide->getShapes()->get_Item($i); } $i++; } return nil; }
public static function run($dataDir = null) { # initialize barcode reader $img = $dataDir . "barcode.jpg"; $barcode_reader_type = new BarCodeReadType(); $rd = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # read barcode while (java_values($rd->read())) { # print the code text, if barcode found print "CodeText: " . (string) $rd->getCodeText(); # print the symbology type print "Type: " . (string) $rd->getReadType() . PHP_EOL; } }
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 static function run($dataDir = null) { $img = $dataDir . "barcode.jpg"; # initialize barcode reader $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # Call read method while (java_values($reader->read())) { print "Barcode CodeText: " . (string) $reader->getCodeText() . " Barcode Type: " . (string) $reader->getReadType() . PHP_EOL; $percent = $reader->getRecognitionQuality(); print "Barcode Quality Percentage: " . (string) $percent . PHP_EOL; } # Close reader $reader->close(); }
private static function removeSectionBreaks($doc) { // Loop through all sections starting from the section that precedes the last one // and moving to the first section. $i = $doc->getSections()->getCount(); $i = java_values($i); $i = $i - 2; while ($i >= 0) { // Copy the content of the current section to the beginning of the last section. $doc->getLastSection()->prependContent($doc->getSections()->get($i)); // Remove the copied section. $doc->getSections()->get($i)->remove(); $i--; } }
function get() { echo "hello Java Handler here"; $CA = new Java("calculator.CalculatorBean"); $session = java_session(); if (is_null(java_values($calcinstance = $session->get("calculatorInstance")))) { $session->put("calculatorInstance", $calcinstance = new Java("calculator.CalculatorBean")); } echo "<br>after calcultator"; echo "<br>session from java = " . java_values($calcinstance = $session->get("calculatorInstance")); if (eregi('^/java/rpc/*', $_SERVER['REQUEST_URI'])) { $RPC = new Java("rpc.test.RpcConsumer"); $RPC->test(); echo "<br> RPC Service on 8082 "; } }
public static function runsByStyleName($doc, $styleName) { // Create an array to collect runs of the specified style. $runsWithStyle = new Java("java.util.ArrayList"); // Get all runs from the document. $nodeType = Java("com.aspose.words.NodeType"); $runs = $doc->getChildNodes($nodeType->RUN, true); // Look through all runs to find those with the specified style. $runs = $runs->toArray(); foreach ($runs as $run) { if (java_values($run->getFont()->getStyle()->getName()->equals($styleName))) { $runsWithStyle->add($run); } } return $runsWithStyle; }
public static function run($dataDir = null) { # Open the stream. Read only access is enough for Aspose.BarCode to load an image. $stream = new FileInputStream($dataDir . "test.png"); # Create an instance of BarCodeReader class # and specify an area to look for the barcode $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($stream, new Rectangle(0, 0, 10, 50), $barcode_reader_type->Code39Standard); # TRead all barcodes in the provided area while (java_values($reader->read())) { # Display the codetext and symbology type of the barcode found print "Codetext: " . (string) $reader->getCodeText() + " Symbology: " . (string) $reader->getReadType() . PHP_EOL; } # Close reader $reader->close(); }
public function fieldMerging(FieldMergingArgs $e) { if ($this->mBuilder == null) { $this->mBuilder = new DocumentBuilder($e->getDocument()); } if ($e->getFieldValue() instanceof Boolean) { $this->mBuilder->moveToMergeField($e->getFieldName()); $checkBoxName = $this->mF->format("{0}{1}", $e->getFieldName(), $e->getRecordIndex()); $this->mBuilder->insertCheckBox($checkBoxName, (bool) $e->getFieldValue(), 0); return; } if (java_values($e->getFieldName()) == 'Subject') { $this->mBuilder->moveToMergeField($e->getFieldName()); $textInputName = $this->mF->format("{0}{1}", $e->getFieldName(), $e->getRecordIndex()); $this->mBuilder->insertTextInput($textInputName, $this->tffT->REGULAR, "", $e->getFieldValue(), 0); } }
public static function run($dataDir = null) { # Instantiate Presentation class that represents the presentation file $pres = new Presentation($dataDir . 'demo.pptx'); # Getting last slide index $last_slide_position = java_values($pres->getSlides()->size()); #Iterating through every presentation slide and generating SVG image $i = 0; while ($i < $last_slide_position) { # Accessing Slides $slide = $pres->getSlides()->get_Item($i); # Getting and saving the slide SVG image $slide->writeAsSvg(new FileOutputStream($dataDir . "SvgImage#{$i}.svg")); $i++; } print "Created SVG images, please check output files." . PHP_EOL; }
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(); }
public static function create_thumbnail_in_notes_slides_view($dataDir = null) { # Instantiate Presentation class that represents the presentation file $pres = new Presentation($dataDir . 'demo.pptx'); # Access the first slide $slide = $pres->getSlides()->get_Item(0); # User defined dimension $desired_x = 1200; $desired_y = 800; # Getting scaled value of X and Y $scale_x = 1.0 / java_values($pres->getSlideSize()->getSize()->getWidth()) * $desired_x; $scale_y = 1.0 / java_values($pres->getSlideSize()->getSize()->getHeight()) * $desired_y; # Create a full scale image $image = $slide->getNotesSlide()->getThumbnail($scale_x, $scale_y); # Save the image to disk in JPEG format $imageIO = new ImageIO(); $imageIO->write($image, "jpeg", new File($dataDir . "ContentBG_tnail.jpg")); print "Created thumbnail in notes slides view, please check the output file." . PHP_EOL; }
public static function run($dataDir = null) { $pres = new Presentation(); # Get the first slide $sld = $pres->getSlides()->get_Item(0); # Define columns with widths and rows with heights $dblCols = [50, 50, 50]; $dblRows = [50, 30, 30, 30, 30]; # Add table shape to slide $tbl = $sld->getShapes()->addTable(100, 50, $dblCols, $dblRows); $fill_type = new FillType(); $color = new Color(); # Set border format for each cell $row = 0; while ($row < java_values($tbl->getRows()->size())) { $cell = 0; while ($cell < $tbl->getRows()->get_Item($row)->size()) { $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->setWidth(5); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->setFillType($fill_type->Solid); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($color->RED); $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->setWidth(5); $cell++; } $row++; } # Merge cells 1 & 2 of row 1 $tbl->mergeCells($tbl->getRows()->get_Item(0)->get_Item(0), $tbl->getRows()->get_Item(1)->get_Item(0), false); # Add text to the merged cell $tbl->getRows()->get_Item(0)->get_Item(0)->getTextFrame()->setText("Merged Cells"); # Write the presentation as a PPTX file $save_format = new SaveFormat(); $pres->save($dataDir . "CreateTable.pptx", $save_format->Pptx); print "Created table, please check the output file." . PHP_EOL; }
public static function run($dataDir = null) { $img = $dataDir . "barcode.jpg"; # initialize barcode reader $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # Set recognition mode $recognitionMode = new RecognitionMode(); $reader->setRecognitionMode($recognitionMode->ManualHints); # Set manual hints $manualHint = new ManualHint(); $reader->setManualHints($manualHint->InvertImage); $reader->setManualHints($manualHint->IncorrectBarcodes); # Call read method while (java_values($reader->read())) { print "Barcode CodeText: " . (string) $reader->getCodeText() . PHP_EOL; } # Close reader $reader->close(); }
/** * This method is called by the Aspose.Words find and replace engine for each match. * This method highlights the match string, even if it spans multiple runs. */ public static function replacing($e) { // This is a Run node that contains either the beginning or the complete match. $currentNode = $e->getMatchNode(); // The first (and may be the only) run can contain text before the match, // in this case it is necessary to split the run. if (java_values($e->getMatchOffset()) > 0) { $currentNode = ReplaceEvaluatorFindAndHighlight::splitRun($currentNode, $e->getMatchOffset()); } // This array is used to store all nodes of the match for further highlighting. $runs = new Java("java.util.ArrayList"); // Find all runs that contain parts of the match string. $remainingLength = $e->getMatch()->group()->length(); while (java_values($remainingLength) > 0 && java_values($currentNode) != null && java_values($currentNode->getText()->length()) <= java_values($remainingLength)) { $runs->add($currentNode); $remainingLength = java_values($remainingLength) - java_values($currentNode->getText()->length()); // Select the next Run node. // Have to loop because there could be other nodes such as BookmarkStart etc. do { $currentNode = $currentNode->getNextSibling(); $nodeType = Java("com.aspose.words.NodeType"); } while (java_values($currentNode) != null && java_values($currentNode->getNodeType()) != java_values($nodeType->RUN)); } // Split the last run that contains the match if there is any text left. if (java_values($currentNode) != null && java_values($remainingLength) > 0) { ReplaceEvaluatorFindAndHighlight::splitRun($currentNode, $remainingLength); $runs->add($currentNode); } // Now highlight all runs in the sequence. $runs = $runs->toArray(); $color = Java("java.awt.Color"); foreach ($runs as $run) { $run->getFont()->setHighlightColor('yellow'); } // Signal to the replace engine to do nothing because we have already done all what we wanted. $replaceAction = Java("com.aspose.words.ReplaceAction"); return $replaceAction->SKIP; }
public static function run($dataDir = null) { # initialize barcode reader $img = $dataDir . "barcode.jpg"; $barcode_reader_type = new BarCodeReadType(); $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard); # Try to recognize all possible barcodes in the image while (java_values($reader->read())) { # Get the region information $region = $reader->getRegion(); if ($region != null) { # Display x and y coordinates of barcode detected $point = $region->getPoints(); print "Top left coordinates: X = " . (string) $point[0]->x . ", Y = " . (string) $point[0]->y . PHP_EOL; print "Bottom left coordinates: X = " . (string) $point[1]->x . ", Y = " . (string) $point[1]->y . PHP_EOL; print "Bottom right coordinates: X = " . (string) $point[2]->x . ", Y = " . (string) $point[2]->y . PHP_EOL; print "Top right coordinates: X = " . (string) $point[3]->x . ", Y = " . (string) $point[3]->y . PHP_EOL; } print "Codetext: " . (string) $reader->getCodeText() . PHP_EOL; } # Close reader $reader->close(); }