I would like to merge info into a regular text file that is directly inside a zip file. I cannot figure it out but I believe this is possible as the documentation says, "all zip archives containing Xml/Html/Text files can be merged with OpenTBS."
My zip file has a custom extension (".kos") but it is really just a zip file. How can I do this? Is there a special way or directory I should have my text file in the zip file? Right now it is literally a zip file and the only contents is the text file.
I am using the following code which works with docx files but not with my custom zip file/text file.
Code snippet:
...
$finalsql = $sth->fetchAll(PDO::FETCH_OBJ);
$template = 'invoice.kos';
$TBS->LoadTemplate(__DIR__ . '/uploads/' . $template, OPENTBS_ALREADY_UTF8);
$TBS->MergeBlock('a', $finalsql);
$save_as = (isset($_POST['save_as']) && (trim($_POST['save_as'])!=='') && ($_SERVER['SERVER_NAME']=='localhost')) ? trim($_POST['save_as']) : '';
$output_file_name = str_replace('.', '_'.date('m-d-Y').'-'.$save_as.'.', $template);
if ($save_as==='') {
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name);
exit();
} else {
$TBS->Show(OPENTBS_FILE, $output_file_name);
exit("File [$output_file_name] has been created.");
}
|