Categories > OpenTBS with DOCX >

OpenTBS block speed problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: PeteA
Date: 2013-06-14
Time: 13:05

OpenTBS block speed problem

Hi,

I'm using OpenTBS to perform an advanced MailMerge type of application.  What I have is a data file with records of people in.  Each person needs to be spent a specific 2-page letter in the order defined in the data file.  So for example, person 1 might need to have letter variant 1, person 2 might need variant 1, person 3 variant 2, person 4 variant 6, person 5 variant 1, etc.

My word template contains [onshow;block=begin;when [data.column1]=X]Two pages of letter[onshow;block=end] for each variant (where X is the variant number).  The first field has [data.column2;block=w:body] to repeat the whole template for each data row.

Everything works brilliantly, I'm getting out the correct variants in the correct order.  However where the issue lies is that for every record read, the time increases incrementally.  20 rows takes 5.7 seconds, 50 rows takes 36.5 seconds and 200 rows takes 592.5 seconds?  So I'm going from a row taking 0.3 seconds per row up to almost 3 seconds.

At a guess I'd say that TinyButStrong is reading through the document being compiled every time rather than just appending to it.  Is there something I can do to solve this, some kind of modification that remembers the a pointer?  Based on the 20 row speed I should theoretically be able to process my file in under 10 minutes ;)

Thanks,

Pete
By: Skrol29
Date: 2013-06-16
Time: 00:11

Re: OpenTBS block speed problem

Hi PeteA,

The problem id that you are using [onshow] blocks to perform the conditional display on sections that are merged with records.
You should use Conditional Sections of block instead.

See http://www.tinybutstrong.com/manual.php#html_conditional
By: PeteA
Date: 2013-06-17
Time: 13:10

Re: OpenTBS block speed problem

Hi Skrol,

Thanks for the information, through a load of messing around, I've actually managed to get this to work.  My original word document was along this lines:

[onshow;block=begin;when [data.column1]=1][data.column2;block=w:body]LETTER1[onshow;block=end]
[onshow;block=begin;when [data.column1]=2][data.column2;block=w:body]LETTER2[onshow;block=end]
[onshow;block=begin;when [data.column1]=3][data.column2;block=w:body]LETTER3[onshow;block=end]
[onshow;block=begin;when [data.column1]=4][data.column2;block=w:body]LETTER4[onshow;block=end]
[onshow;block=begin;when [data.column1]=5][data.column2;block=w:body]LETTER5[onshow;block=end]
[onshow;block=begin;when [data.column1]=6][data.column2;block=w:body]LETTER6[onshow;block=end]

But I have now rejigged it to the following:

[data;block=begin;when [data.column1]=1][data.column2] LETTER1[data;block=end]
[data;block=begin;when [data.column1]=2][data.column2] LETTER2[data;block=end]
[data;block=begin;when [data.column1]=3][data.column2] LETTER3[data;block=end]
[data;block=begin;when [data.column1]=4][data.column2] LETTER4[data;block=end]
[data;block=begin;when [data.column1]=5][data.column2] LETTER5[data;block=end]
[data;block=begin;when [data.column1]=6][data.column2] LETTER6[data;block=end]

This solves all of the issues I originally had and allows me to have any content between the block=begin and block=end tags, including page breaks, images etc.  1000 records are being processed in around 200 seconds (this makes a word file of 2000 pages).

Hopefully this helps if anybody else comes across this problem!

Cheers

Pete
By: Skrol29
Date: 2013-06-17
Time: 22:39

Re: OpenTBS block speed problem

And you could try the new feature in OpenTBS 1.8.0 : block alias.
You could then replace "block=begin"/"block=end" with "block=tbs:page".

Regards,
By: PeteA
Date: 2013-06-18
Time: 10:36

Re: OpenTBS block speed problem

I've never got tbs:page to work for me, even ensuring I've got the page break paragraph setting in place :s  Not sure why to be honest!