Пример #1
0
 public static function main()
 {
     // The path to the documents directory.
     $dataDir = "/usr/local/apache-tomcat-8.0.22/webapps/JavaBridge/Aspose_Words_Java_For_PHP/src/programmingwithdocuments/workingwithimages/compressimages/data/";
     $srcFileName = $dataDir . "Test.docx";
     $messageFormat = new Java("java.text.MessageFormat");
     $file_size = CompressImages::getFileSize($srcFileName);
     echo java_values($messageFormat->format("Loading {0}. Size {1}.", $srcFileName, $file_size));
     die("I M HERE");
     $doc = new Java("com.aspose.words.Document", $srcFileName);
     // 220ppi Print - said to be excellent on most printers and screens.
     // 150ppi Screen - said to be good for web pages and projectors.
     // 96ppi Email - said to be good for minimal document size and sharing.
     $desiredPpi = 150;
     // In Java this seems to be a good compression / quality setting.
     $jpegQuality = 90;
     // Resample images to desired ppi and save.
     $resampler = new Java("com.aspose.words.Resampler");
     $count = $resampler->resample($doc, $desiredPpi, $jpegQuality);
     echo $MessageFormat->format("Resampled {0} images.", $count);
     if ($count != 1) {
         echo "<br> We expected to have only 1 image resampled in this test document!";
     }
     $dstFileName = $srcFileName . "Resampled Out.docx";
     $doc->save($dstFileName);
     echo $messageFormat->format("Saving {0}. Size {1}.", $dstFileName, CompressImages::getFileSize($dstFileName));
     // Verify that the first image was compressed by checking the new Ppi.
     $doc = new Java("com.aspose.words.Document", $dstFileName);
     $nodeType = new Java("com.aspose.words.NodeType");
     $shape = $doc->getChild($nodeType->DRAWING_ML, 0, true);
     $convertUtil = new Java("com.aspose.words.ConvertUtil");
     $imagePpi = $shape->getImageData()->getImageSize()->getWidthPixels() / $convertUtil->pointToInch($shape->getSize()->getX());
     if ($imagePpi < 150) {
         echo "Image was not resampled successfully.";
     }
 }
Пример #2
0
Файл: jver.php Проект: OTiZ/osx
<html>
<?

  $system = new Java("java.lang.System");
  print "Java version=".$system->getProperty("java.version")." <br>\n";
  print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n";
  print "OS=".$system->getProperty("os.name")." ".
	      $system->getProperty("os.version")." on ".
	      $system->getProperty("os.arch")." <br>\n";

  $formatter = new Java("java.text.SimpleDateFormat",
			"EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");

  print $formatter->format(new Java("java.util.Date"))."\n";

?>
</html>
Пример #3
0
<?php

//phpinfo();
include "phpjasper/Java.inc";
$system = new Java('java.lang.System');
// accéder aux propriétés
echo 'Java version=' . $system->getProperty('java.version') . ' <br />';
echo 'Java vendor=' . $system->getProperty('java.vendor') . '<br />';
echo 'OS=' . $system->getProperty('os.name') . ' ' . $system->getProperty('os.version') . ' on ' . $system->getProperty('os.arch') . '<br />';
$formater = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");
echo $formater->format(new Java('java.util.Date'));
?>
                    
Пример #4
0
 /**
  *
  * @param string
  * The name of a {@link Property} of $this {@link Node}
  * @param mixed
  * The value to be assigned
  * @param int|null
  * The type of the {@link Property} (Optional: NULL if not
  * specified).
  * @return object
  * A {@link Property} object
  * @throws {@link ValueFormatException}
  * If <i>$value</i> cannot be converted to the specified type or
  * if the property already exists and is multi-valued.
  * @throws {@link VersionException}
  * If this node is versionable and checked-in or is non-versionable but
  * its nearest versionable ancestor is checked-in and this implementation
  * performs this validation immediately instead of waiting until
  * {@link save()}.
  * @throws {@link LockException}
  * If a lock prevents the setting of the property and this implementation
  * performs this validation immediately instead of waiting until
  * {@link save()}.
  * @throws {@link ConstraintViolationException}
  * If the change would violate a node-type or other constraint and this
  * implementation performs this validation immediately instead of
  * waiting until {@link save()}.
  * @throws {@link RepositoryException}
  * If another error occurs.
  * @see PHPCR_Node::setProperty()
  */
 public function setProperty($name, $value, $type = 1)
 {
     $isNew = true;
     if ($this->hasProperty($name)) {
         $isNew = false;
     }
     $filename = null;
     switch ($type) {
         case PHPCR_PropertyType::BINARY:
             $pr = new Java("javax.jcr.PropertyType");
             $type = $pr->BINARY;
             $strlen = strlen($value);
             // keep it in memory, if small
             if ($strlen < 500) {
                 $out = new Java("java.io.ByteArrayOutputStream");
                 $arr = array();
                 for ($i = 0; $i < $strlen; $i++) {
                     $val = ord(substr($value, $i, 1));
                     if ($val >= 128) {
                         $val = $val - 256;
                     }
                     $arr[] = $val;
                 }
                 $out->write($arr);
                 $value = new Java("java.io.ByteArrayInputStream", $out->toByteArray());
             } else {
                 $filename = tempnam(sys_get_temp_dir(), "jrcr");
                 chmod($filename, 0666);
                 file_put_contents($filename, $value);
                 $value = new Java("java.io.FileInputStream", $filename);
             }
             break;
         case PHPCR_PropertyType::DATE:
             $pr = new Java("javax.jcr.PropertyType");
             $type = $pr->DATE;
             //$ValueFactory = new Java("javax.jcr.ValueFactory");
             $cal = new Java("java.util.Calendar");
             $val = $cal->getInstance();
             if ($value instanceof DateTime) {
                 $val->setTimeInMillis($value->format('U') * 1000);
             } else {
                 $val->setTimeInMillis($value * 1000);
             }
             $value = $val;
             break;
     }
     if (!is_object($value) && $type) {
         $jrprop = $this->JRnode->setProperty($name, $value, $type);
     } elseif ($value instanceof jr_cr_node) {
         $jrprop = $this->JRnode->setProperty($name, $value->JRnode);
     } else {
         $jrprop = $this->JRnode->setProperty($name, $value);
     }
     if (null === $jrprop) {
         throw new PHPCR_RepositoryException("Couldn't create new property");
     }
     if ($filename) {
         unlink($filename);
     }
     $property = new jr_cr_property($this, $jrprop);
     $this->addPropertyToList($property);
     if ($isNew) {
         $property->setNew(true);
     }
     $property->setModified(true);
     $this->setModified(true);
     if ($this->session->cache) {
         $this->session->cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
 }
        } else {
            echo "java extension not installed.";
        }
    }
}
check_extension();
if (1) {
    phpinfo();
    print "\n\n";
    $v = new Java("java.lang.System");
    $p = @$v->getProperties();
    if ($ex = java_last_exception_get()) {
        $trace = new Java("java.io.ByteArrayOutputStream");
        $ex->printStackTrace(new java("java.io.PrintStream", $trace));
        echo "Exception {$ex} occured:<br>\n" . $trace . "\n";
        exit(1);
    }
    $arr = $p;
    foreach ($arr as $key => $value) {
        print $key . " -> " . $value . "<br>\n";
    }
    echo "<br>\n";
    echo "<br>\n";
    // java.util.Date example
    $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");
    print $formatter->format(new Java('java.util.Date'));
    echo "<br>\n";
} else {
    phpinfo();
    print "\n\n";
}