Accessing stroke information

This example shows how to access detailed stroke data including x, y, force and page:

<?php //File: MyHandlers.php class MyHandlers { function addEventHandlers (RequestContext $ctx) { $ctx->addEventHandler (ActionEvent::FIELDS_PROCESSED, $this, "onFieldsProcessed"); } /** * Implements access to strokes data. Stores the data in $strokesarr */ function onFieldsProcessed(ActionEvent $event) { $strokesarr = $this->strokesdump($event->penDocument); // now use $strokesarr for whatever you like... file_put_contents("/tmp/strokesdump.txt", print_r($strokesarr, true)); } // Convert low level coordinates to millimeters private function strokesCoordinateToMM($coord) { return (((($coord-256)/8)*0.3)); } private function strokesdump(PenDocument $penDoc) { $arr = array(); foreach($penDoc->pages as $page) { $pagearr=array(); foreach($page->strokes as $stroke) { $strokearr=array(); foreach($stroke->points as $point) { $p=array("x" => $point[0], "y"=>$point[1], "force" => $point[2], "x_mm" => $this->strokesCoordinateToMM($point[0]), "y_mm" => $this->strokesCoordinateToMM($point[1])); $strokearr[] = $p; } $pagearr[] = $strokearr; } $arr[$page->address] = $pagearr; } return($arr); } } ?>
Was this article useful? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us