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");
 }
 public static function ConvertNumPageFields()
 {
     $dstDoc = new Java("com.aspose.words.Document", AppendDocument::$gDataDir . "TestFile.Destination.doc");
     $srcDoc = new Java("com.aspose.words.Document", AppendDocument::$gDataDir . "TestFile.Source.doc");
     // Restart the page numbering on the start of the source document.
     $srcDoc->getFirstSection()->getPageSetup()->setRestartPageNumbering(true);
     $srcDoc->getFirstSection()->getPageSetup()->setPageStartingNumber(1);
     // Append the source document to the end of the destination document.
     $importFormatMode = new Java("com.aspose.words.ImportFormatMode");
     $dstDoc->appendDocument($srcDoc, $importFormatMode->KEEP_SOURCE_FORMATTING);
     // After joining the documents the NUMPAGE fields will now display the total number of pages which
     // is undesired behaviour. Call this method to fix them by replacing them with PAGEREF fields.
     AppendDocument::convertNumPageFieldsToPageRef($dstDoc);
     // This needs to be called in order to update the new fields with page numbers.
     $dstDoc->updatePageLayout();
     $dstDoc->save(AppendDocument::$gDataDir . "TestFile.ConvertNumPageFields Out.doc");
 }