Categories > OpenTBS with ODT >

Re: mailmerge 1 template produce 1 docx with multiple pages how?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: NinoV
Date: 2012-01-29
Time: 08:24

Re: mailmerge 1 template produce 1 docx with multiple pages how?

Hi Skrol29,

as Sam I would like to produce a  single odt document with a page for each single student.

I've played around with OpenTBS, but I failed to understand how it works :(

I would be very grateful to you if you could give me a dummy's example: one odt template and the php script to produce the single merged document.

Thank you very much,
Nino
By: Skrol29
Date: 2012-01-30
Time: 09:27

Re: mailmerge 1 template produce 1 docx with multiple pages how?

hi Nivo,

You've previously posted you question on the Microsoft Office Forum. I've moved it here.

There is an example of merging ODT with 1 record per page. The example is provided with the OpenTBS package and is also available on line.

The principle is to use the following synopsis for your template

<---- a standalone paragraph containing the field [b;block=begin;comm=text:p] ---->
<---- a page break here ---->
... Page content here ...
<---- a standalone paragraph containing the field [b;block=end;comm=text:p] ---->
By: NinoV
Date: 2012-01-30
Time: 09:42

Re: mailmerge 1 template produce 1 docx with multiple pages how?

Hi Skrol29,

thank you for your  quick reply.

I read the example you refer to, but it didn't work, so I thought that should be another method.

I'll try again.

Sorry for having post on the wrong forum :(

Nino
By: Skrol29
Date: 2012-01-30
Time: 22:29

Re: mailmerge 1 template produce 1 docx with multiple pages how?

> but it didn't work

It is working one line as it should work in your PC.
Can you give more details ? What did not work ? Did you have an error message? What was not as you expected ?

Regards,
By: NinoV
Date: 2012-01-31
Time: 18:25

Re: mailmerge 1 template produce 1 docx with multiple pages how?

I get this message: "Format error discovered in the file in sub-document content.xml at 2,11636"

I think the problem doesn't relate to TBS, but my coding:

while ($a_row = fetch_array($result)) {
    if ($a_row["clfoco"]>103){
        $anagrafica = new Anagrafica();
        $donatore = $anagrafica->getPartner($a_row["clfoco"]);

        $array=array('cognome'=>$donatore["ragso1"],
            'nome'=>$donatore["ragso2"],
            'sesso'=>$donatore["sexper"],
            'citta'=>$donatore["citspe"],
            'indir'=>$donatore["indspe"],
            'cap'=>$donatore["capspe"],
            'prov'=>$donatore["prospe"],
            'paese'=>$donatore["country"],
            'email'=>$donatore["e_mail"]);
    }else{
        $array=array('cognome'=>"Non assegnatoa",
        'nome'=>"-",                                          
        'sesso'=>"-",
        'citta'=>"-",
        'indir'=>"-",
        'cap'=>"-",
        'prov'=>"-",
        'paese'=>"-",
        'email'=>"-");
    }                                                                                  
    if ($array['sesso']==='F'){
        $array['saluto']='Carissima '.$array['nome'];
    }elseif ($array['sesso']==='M'){
        $array['saluto']='Carissimo '.$array['nome'];
    }else{
        $array['saluto']='Carissimi';
    }
    $n++;
    $aTBSDonatori[]=$array;
}
By: Skrol29
Date: 2012-01-31
Time: 21:44

Re: mailmerge 1 template produce 1 docx with multiple pages how?

This snippet is building the $array variable for merging.
But what is the code that performs the mering ,and what is the related piece of template?
By: NinoV
Date: 2012-02-01
Time: 05:50

Re: mailmerge 1 template produce 1 docx with multiple pages how?

I'm very sorry!

I call the following function by letteraTBS($aTBSDonatori):


function letteraTBS($array){
    include_once('tbs/tbs_class.php');
    include_once('tbs/plugins/tbs_plugin_opentbs.php');
    $TBS = new clsTinyButStrong;
    $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

    $template = 'odt/lettere_microtbs.odt';
    $TBS->LoadTemplate($template,OPENTBS_ALREADY_UTF8);
   
        $TBS->MergeBlock('s', $S);
    $file_name = 'barua_'.date('YmdHis').'.odt';

    $TBS->Show(OPENTBS_FILE+TBS_EXIT, $file_name);
}

This is the template:


[s;block=begin;comm=text:p]
--- pagebreak----
--- letter headings with an image ---

[s.nome] [s.cognome]
[s.indir]
[s.cap] [s.citta] [s.prov]
[s.email]

[s.Saluto]
----- some text --------
[s;block=end;comm=text:p]

All works fine if the array contains only one record, but I get the error with more records.

Thanks a lot for your help!
Nino
By: NinoV
Date: 2012-02-02
Time: 10:33

Re: mailmerge 1 template produce 1 docx with multiple pages how?

I think I 've found what was "wrong" in my template. I had to delete all pagebreaks following the first one. Is that a bug or a "to-do"?

Anyway now my problem is solved.

Thank you very much.
Nino