Categories > OpenTBS with DOCX >

Change Header and footer in template

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Locs
Date: 2015-12-03
Time: 22:44

Change Header and footer in template

Hi,
i've got a template template that contain my header in docx so (header1.xml,header2.xml and header3.xml)

And i want to add this header file in another document, what is the best way for doing this?

Thanks a lot.
By: Locs
Date: 2015-12-04
Time: 10:12

Re: Change Header and footer in template

Hi actually i do this :
$TBSHeader->LoadTemplate($monHeader.'#word/header1.xml');
$TBSHeader->Show(TBS_NOTHING);
$tbsHeaderStr=$TBSHeader->Source;

$TBS->LoadTemplate('./'.$monFichier,OPENTBS_ALREADY_UTF8);
$TBS->Plugin(OPENTBS_ADDFILE,'word/header1.xml',$tbsHeaderStr,$DataType=OPENTBS_STRING,$Compress=true);
But in the the result i don't have header add.
If i do that :
$TBS->LoadTemplate('./'.$monFichier,OPENTBS_ALREADY_UTF8);

$TBSHeader->LoadTemplate($monHeader.'#word/header1.xml');
$TBSHeader->Show(TBS_NOTHING);
$tbsHeaderStr=$TBSHeader->Source;

$TBS->Plugin(OPENTBS_ADDFILE,'word/header1.xml',$tbsHeaderStr,$DataType=OPENTBS_STRING,$Compress=true);
In the result i only have the header not the word template merge.

What i'm doing wrong?
By: Locs
Date: 2015-12-04
Time: 16:09

Re: Change Header and footer in template

I try to add my header with TbsZip function like this :
$TBS->TbsZip->Open($monHeader);
$tbsHeaderStr=$TBS->TbsZip->FileRead('word/header1.xml');
$TBS->TbsZip->Close();

$TBS->LoadTemplate('./'.$monFichier,OPENTBS_ALREADY_UTF8);
$TBS->Plugin(OPENTBS_ADDFILE,'#word/header1.xml',$tbsHeaderStr,$DataType=OPENTBS_STRING);

$TBS->LoadTemplate('#word/header1.xml');

But i've got this error :
TinyButStrong Error OpenTBS Plugin: Cannot load "word/header1.xml". The file is not found in the archive ".//uploads/media/Modeles editions/0001/01/de3a1ae4a390bddd02ed889cbe5a7c178361739b.docx". The process is ending, unless you set NoErr property to true.

The OPENTBS_ADDFILE plugin seems not working? I can't use OPENTBS_REPLACEFILE because my template doesn't have header yet!!!!

Is there a solution?
Thanks
By: Locs
Date: 2015-12-04
Time: 18:24

Re: Change Header and footer in template

There is no solution?
By: Skrol29
Date: 2015-12-05
Time: 23:50

Re: Change Header and footer in template

The OpenXML file format expects that you declare the added files at the proper places.
Header and footer have to be declared somewhere. I don"t know exactly where in the DOCX but it may be at different places.

Combining two different DOCX may be quite difficult.