/** * @param $outDocxFilePath * @param bool $addPageBreak * @return bool * @throws \Exception */ public function save($outDocxFilePath, $addPageBreak = false) { if (!count($this->files)) { // No files to merge return false; } if (!copy($this->files[0], $outDocxFilePath)) { // Cannot create file throw new \Exception("error saving output file {$outDocxFilePath}"); } $docx = new DocxLib\Docx($outDocxFilePath); for ($i = 1; $i < count($this->files); $i++) { $docx->addFile($this->files[$i], "part" . $i . ".docx", "rId10" . $i, $addPageBreak); } $docx->flush(); return true; }