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 />"; } }