Categories > OpenTBS with ODT >

creating a multi-page document, reusing the same template

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: william
Date: 2010-07-03
Time: 18:38

creating a multi-page document, reusing the same template

My next project is to write a php script to create patient statements.  I need to merge the same template with different patient data, creating a multi-page document oo file.
I can easily figure out how to create one patient's statement, but can't figure out how to repeatedly merge different data with the same template file, with the results of each merge going into one file.

All assistance gratefully appreciated.

bill
By: Skrol29
Date: 2010-07-04
Time: 23:28

Re: creating a multi-page document, reusing the same template

Hi Bill,

I don't know how to merge several document into a unique one. Nevertheless, it is possible to have a template which is merged with a new page break for each record. The result is the same. The template which is given with the demo does it.
By: william
Date: 2010-07-05
Time: 11:52

Re: creating a multi-page document, reusing the same template

The demo has a single document with a page break in the middle, if memory serves.
I can't figure a way to use that because I have n pages and do not know how many statements will be prepared until the end of the merge.
I suppose I could write out each statement as a separate file, but that gets really difficult to print them.

Maybe it would be better to write the file out as a mail merge and then merge them.  Can OpenTBS write a mail merge file ?

bill
By: william
Date: 2010-07-05
Time: 14:44

Re: creating a multi-page document, reusing the same template

It is not so simple as I would wish.
I could write a .csv file, but lose all the formatting - I would really like an OpenTBS solution.
By: william
Date: 2010-07-05
Time: 15:02

Re: creating a multi-page document, reusing the same template

Idea:
Please excuse my relative ignorance of TBS, but...
As source is modified as soon as a merge is done, is it feasible that I could:
read in the template (OO),
merge the fields and blocks,
read in the template again (using the "+" parameter for "charset"),
merge the fields and blocks again...

If you see not obvious reason why this will not work, I will play with it, but I would like your opinion before I spend the time.

Many thanks,

bill
By: Skrol29
Date: 2010-07-06
Time: 19:05

Re: creating a multi-page document, reusing the same template

Hi Bill,

Unfortunately you cannot merge several documents using the "+" as the charset argument. Each OpenOffice document begin with XML entities that are specifics to the type of document, and includes lot of parameters related to the doc (styles, ...). If you just concatenate the XML contents this will produce a wrong XML content.

I don't see the difficulty about adapting the demo template for your patient statements. The idea of this technical is to have a block "b" which begins with a page break, and finish where you want with a TBS tag. The bloc can be then merged with your statements. There will be a new page break before each statement, and statements even have several pages if needed.
By: william
Date: 2010-07-07
Time: 12:37

Re: creating a multi-page document, reusing the same template

Thank you for redirecting me, I will play with the demo and see what I can do.
By: william
Date: 2010-07-07
Time: 12:55

Re: creating a multi-page document, reusing the same template

The demo takes one array and puts one row on each of several pages.  Very clever.
Is it possible to have, on each page:
several fields
block a with multiple rows (a variable number)
block b with multiple rows
block c with multiple rows
block d with multiple rows
several more fields

bill
By: Skrol29
Date: 2010-07-07
Time: 15:59

Re: creating a multi-page document, reusing the same template

Hi,

You can merge a main block, one row per page, and each row can contains itself several subsets of row to be merged. This is called sub-block in TBS. There is an example of sub-blocks in the example page.
By: william
Date: 2010-07-07
Time: 16:54

Re: creating a multi-page document, reusing the same template

Thanks, back to the documentation.
bill
By: william
Date: 2010-08-04
Time: 12:38

Re: creating a multi-page document, reusing the same template

Almost there: Thanks !
I have the subblocks part working well now (form the SubBlocks thread) but when I combine the example from "demo" for multi-page merge with the subblocks I get only the outer merge done:
e.g: template

[asb;block=begin;comm=text:p ] (put this tag in a separate paragraph)
--page break--
-table1 start-
name: [asb.name; block=table:table-row;sub1=services;sub2=payments;sub3=adjustments] date: [asb.SDate]
Services
-subTable1 start-
[asb_sub1.dos; block=table:table-row] [asb_sub1.desc][asb_sub1.charge]
-subTable1 end-
Payments
-subTable2 start-
[asb_sub2.dos; block=table:table-row] [asb_sub2.desc] [asb_sub2.pmt]
Adjustments
-subTable3 start-
[asb_sub3.dos; block=table:table-row] [asb_sub3.desc] [asb_sub3.pmt]
-subTable3 end-
[asb;block=end;comm=text:p] (put this tag in a separate paragraph)
-------end of template----
asb.name and asb.SDate merge fine, but the subblocks are rendered as they are in the template, no merge.

If I do not have the asb;block... statements in the template the subblocks merge fine, but on the same page.

Any thoughts/suggestions ?
Thanks in advance.
bill
By: william
Date: 2010-08-04
Time: 12:39

Re: creating a multi-page document, reusing the same template

In my example I left out the --table end--, but it is there.
By: Skrol29
Date: 2010-08-04
Time: 13:40

Re: creating a multi-page document, reusing the same template

Hi,

Use OpenTBS last version 1.3.2, there is a new debug mode which is very useful to check your template. Try it to see the source of the merged document, near by the sub blocks that are not merged. You'll probably discover that the code of the subblock is split by formating tags.
By: william
Date: 2010-08-04
Time: 14:51

Re: creating a multi-page document, reusing the same template

Here is the debug output for the first table/subtable.  You might see something that I am missing:  (the text "fixed data) is a string in the templatejust before the table begins)
<office:body>
  <office:text text:use-soft-page-breaks="true">
   <text:sequence-decls>
    <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
   </text:sequence-decls>
   <text:p text:style-name="Standard"/>
   <text:p text:style-name="P8"/>
   <text:p text:style-name="P5">
    fixed data
   </text:p>
   <text:p text:style-name="Standard"/>
   <table:table table:name="Table1" table:style-name="Table1">
    <table:table-column table:style-name="Table1.A"/>
    <table:table-row>
     <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="P1">
       name: John Smith date: 8/1/2010
      </text:p>
      <text:p text:style-name="P7">
       Services
      </text:p>
      <table:table table:name="Table2" table:style-name="Table2">
       <table:table-column table:style-name="Table2.A"/>
       <table:table-column table:style-name="Table2.B"/>
       <table:table-column table:style-name="Table2.C"/>
       <table:table-row>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P6">
          [asb_sub1.dos; block=table:table-row]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P6">
          [asb_sub1.desc]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.C1" office:value-type="string">
         <text:p text:style-name="Table_20_Contents">
          [asb_sub1.charge]
         </text:p>
        </table:table-cell>
       </table:table-row>
      </table:table>
      <text:p text:style-name="P3"/>
      <text:p text:style-name="P4">
Note that the first fields (in the outer table) merge-> name: John Smith date: 8/1/2010
and the inner table does not: remains  [asb_sub1.dos; block=table:table-row]

bill
By: Skrol29
Date: 2010-08-04
Time: 15:34

Re: creating a multi-page document, reusing the same template

Strange, indeed,

I assume you've got no error message.
What is your TBS version ? It is given at the top of the debug information.
By: william
Date: 2010-08-05
Time: 14:52

Re: creating a multi-page document, reusing the same template

* OpenTBS version: 1.3.1
* TinyButStrong version: 3.5.0
* PHP version: 5.2.10-2ubuntu6.4
* Opened archive: ./test.odt
* Deleted files in the archive: none
* Added files in the archive: none
* Modified files in the archive:
  - content.xml

BTW: the open TBS version on the server says it is 1.3.2 not 1.3.1
??
bill
By: william
Date: 2010-08-05
Time: 15:02

Re: creating a multi-page document, reusing the same template

Let me figure out why I am getting 1.3.1 instead  of 1.3.2 and 3.5.0 instead of 3.5.3 before we go any further.  I have the right classes in my "classes" directory on the server, but must have another copy somewhere in the path.

bill
By: william
Date: 2010-08-05
Time: 15:18

Re: creating a multi-page document, reusing the same template

I found the old copy (tbs for php4 !) tucked away in a obscure directory.  I now am using 1.3.2 and 3.5.3 and  still have the same problem.
* OpenTBS version: 1.3.1
* TinyButStrong version: 3.5.3
* PHP version: 5.2.10-2ubuntu6.4
* Opened archive: ./test.odt
* Deleted files in the archive: none
* Added files in the archive: none
* Modified files in the archive:
  - content.xml
...
   <text:p text:style-name="Standard"/>
   <text:p text:style-name="P5">
    fixed data
   </text:p>
  <text:p text:style-name="Standard"/>
   <table:table table:name="Table1" table:style-name="Table1">
    <table:table-column table:style-name="Table1.A"/>
    <table:table-row>
     <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="P1">
       name: John Smith date: 8/1/2010
      </text:p>
      <text:p text:style-name="P7">
       Services
      </text:p>
      <table:table table:name="Table2" table:style-name="Table2">
       <table:table-column table:style-name="Table2.A"/>
       <table:table-column table:style-name="Table2.B"/>
       <table:table-column table:style-name="Table2.C"/>
       <table:table-row>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P6">
          [asb_sub1.dos; block=table:table-row]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P6">
          [asb_sub1.desc]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.C1" office:value-type="string">
         <text:p text:style-name="Table_20_Contents">
          [asb_sub1.charge]
         </text:p>
        </table:table-cell>
       </table:table-row>
      </table:table>
...

bill
 
By: william
Date: 2010-08-05
Time: 15:20

Re: creating a multi-page document, reusing the same template

disregard - still shows as 1.3.1 - more searching.
bill
By: william
Date: 2010-08-05
Time: 15:26

Re: creating a multi-page document, reusing the same template

I am flumoxed.

I changed the include_once to explicitly use
tbs_plugin_opentbs-1-3-2.php and renamed the file to that so I am sure I am getting that file, but it still shows 1.3.1 in the debug header.
By: william
Date: 2010-08-05
Time: 15:27

Re: creating a multi-page document, reusing the same template

here is the top of the class file:
<?php

/* OpenTBS version 1.3.2, on 2010-07-22
Author  : Skrol29 (email: http://www.tinybutstrong.com/onlyyou.html)

bill
By: Skrol29
Date: 2010-08-05
Time: 19:17

Re: creating a multi-page document, reusing the same template

Hi Bill,

Sorry for this stupid bug, OpenTBS version 1.3.2 is saying version 1.3.1!
There is now a new version available, it is 1.3.3. It fixes only this bug.

We can see now that your sub-block definition is not split, and TBS should process it because this feature is available since TBS version 3.5.0.

Can you now run the same debug mode, but without calling the MergeBlock('asb') ? It will help to see what is the inner definition of the main block.
By: william
Date: 2010-08-06
Time: 16:25

Re: creating a multi-page document, reusing the same template

* OpenTBS version: 1.3.1
* TinyButStrong version: 3.5.3
* PHP version: 5.2.10-2ubuntu6.4
* Opened archive: ./test1.odt
...
   <text:p text:style-name="Standard"/>
   <table:table table:name="Table1" table:style-name="Table1">
    <table:table-column table:style-name="Table1.A"/>
    <table:table-row>
     <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="P1">
       name: [asb.name; block=table:table-row;sub1=services;sub2=payments;sub3=adjustments] date: [asb.SDate]
      </text:p>
      <text:p text:style-name="P6">
       Services
      </text:p>
      <table:table table:name="Table2" table:style-name="Table2">
       <table:table-column table:style-name="Table2.A"/>
       <table:table-column table:style-name="Table2.B"/>
       <table:table-column table:style-name="Table2.C"/>
       <table:table-row>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P5">
          [asb_sub1.dos; block=table:table-row]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.A1" office:value-type="string">
         <text:p text:style-name="P5">
          [asb_sub1.desc]
         </text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table2.C1" office:value-type="string">
         <text:p text:style-name="Table_20_Contents">
          [asb_sub1.charge]
         </text:p>
        </table:table-cell>
       </table:table-row>
 
By: Skrol29
Date: 2010-08-09
Time: 00:11

Re: creating a multi-page document, reusing the same template

Hi Bill,

Sorry the 1.3.3 version was not available as I said, it would be available now.
Whatever, this would not change the result.

Could you send to me a small sample that would reproduce the problem you have? With just a small PHP array as data to merge.
This will help me to debug the behavior you've got.
By: william
Date: 2010-08-09
Time: 12:15

Re: creating a multi-page document, reusing the same template

sent to your skrol29f...m address.
I will off-net for 2-3 weeks and will check back then.
bill
By: Skrol29
Date: 2010-08-09
Time: 16:58

Re: creating a multi-page document, reusing the same template

Hi bill,

I've found the problem in your ODT template. In fact, you've defined the "asb" block twice. the first time is when there is [asb;block=begin]. The block takes its properties here, and there is no sub1, sub2 or sub3 parameters. In this first definition, you've defined [asb.name;block=table:table-row;;sub1=services...]. But this time all block parameters are ignored, because it has previously been defined.

So you just have to move parameters sub1, sub2, sub3 from this TBS tag to the first one.
By: william
Date: 2010-08-13
Time: 12:42

Re: Re: creating a multi-page document, reusing the same template

thank you very much.  I can now type one finger, but can't get to the debug computer for a couple of more days.
By: william
Date: 2010-08-15
Time: 17:13

Re: creating a multi-page document, reusing the same template

works like a charm.
I appreciate your time and effort more than I can say.
Would you like me to clean it up, document it and submit it as a complex demo as a small payback for all your great work ?
bill
By: william
Date: 2010-08-15
Time: 20:44

Re: creating a multi-page document, reusing the same template

works like a charm.
I appreciate your time and effort more than I can say.
Would you like me to clean it up, document it and submit it as a complex demo as a small payback for all your great work ?
bill