Categories > OpenTBS general >

.txt file inside zip file (with custom extension)

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: silencio
Date: 2016-08-28
Time: 03:21

.txt file inside zip file (with custom extension)

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.");
}


By: silencio
Date: 2016-08-28
Time: 03:50

Re: .txt file inside zip file (with custom extension)

OK, I actually got it to work. I changed

$TBS->LoadTemplate(__DIR__ . '/uploads/' . $template, OPENTBS_ALREADY_UTF8);

to

$TBS->LoadTemplate(__DIR__ . '/uploads/' . $template . '#invoice.txt');
By: Skrol29
Date: 2016-09-01
Time: 01:27

Re: .txt file inside zip file (with custom extension)

ok