CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
}
elseif (!empty($formValues['document_file_path'])) {
- CRM_Utils_PDF_Document::printDocuments($formValues['document_file_path'], $html, $type, $zip);
+ $fileName = pathinfo($formValues['document_file_path'], PATHINFO_FILENAME) . '.' . $type;
+ CRM_Utils_PDF_Document::printDocuments($html, $fileName, $type, $zip);
}
else {
CRM_Utils_PDF_Document::html2doc($html, "CiviLetter.$type", $formValues);
/**
* Modify contents of docx/odt file(s) and later merged into one final document
*
- * @param string $filePath
- * Document file path
* @param array $contents
* Content of formatted/token-replaced document.
* List of HTML snippets.
+ * @param string $fileName
+ * Document file name
* @param string $docType
* Document type e.g. odt/docx
* @param clsTbsZip $zip
*
* @return string
*/
- public static function printDocuments($filePath, $contents, $docType, $zip, $returnFinalContent = FALSE) {
+ public static function printDocuments($contents, $fileName, $docType, $zip, $returnFinalContent = FALSE) {
$dataMap = self::$ooxmlMap[$docType];
$finalContent = $zip->FileRead($dataMap['dataFile']);
// Replace the loaded document file content located at $filePath with $finaContent
$zip->FileReplace($dataMap['dataFile'], $finalContent, TBSZIP_STRING);
- $fileName = pathinfo($filePath, PATHINFO_FILENAME) . '.' . $docType;
$zip->Flush(TBSZIP_DOWNLOAD, $fileName);
}
$html[] = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], TRUE, $messageToken);
}
- $returnContent = CRM_Utils_PDF_Document::printDocuments($formValues['document_file_path'], $html, $type, $zip, TRUE);
+ $fileName = pathinfo($formValues['document_file_path'], PATHINFO_FILENAME) . '.' . $type;
+ $returnContent = CRM_Utils_PDF_Document::printDocuments($html, $fileName, $type, $zip, TRUE);
$returnContent = strip_tags($returnContent);
$this->assertTrue(strpos($returnContent, 'Hello Antonia D`souza') !== 0);