path(config('services.report.word2007.template'))); $variables = [ 'PAT_NAME' => $this->report->study->patient_name, 'PAT_ID' => $this->report->study->patient_id, 'PAT_AGE' => $this->report->study->sexAge(), 'ACC_NUM' => $this->report->study->accession_number, 'REF_DOC' => $this->report->study->referring_physician_name, 'STUDY_DATE' => $this->report->created_at->toDateString(), ]; $img = ['parseLineBreaks' => true, 'target' => 'header']; $docx->replaceVariableByText($variables, $img); $docx->embedHTML($this->report->getContent()); $stamper = new StampService($this->report->read_by_id); if ($stamper->hasSignatureImage()) { $img = [ 'src' => $stamper->signatureImagePath(), 'textWrap' => 0, ]; $docx->addImage($img); } return $docx; } }