Categories > OpenTBS with DOCX >

OpenTBS: page breaks / one page per record

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John Lawler
Date: 2012-02-07
Time: 18:17

OpenTBS: page breaks / one page per record

I read a recent post that touched on this issue somewhat, but I'm trying to build a simple document that will essentially output one page in a single docx per record I read from my database.

I'm new to TBS / OpenTBS and am having a bit of trouble understanding this.  I have a couple basic examples working that I've built myself, based on the included samples, but don't quite have what I want.

I understand that I could do a block=begin / block=end section at the top and bottom of a page, and have a page break included in the block and thus produce multiple pages, but this isn't clean enough for me because then I would have an extra blank page either at the top or bottom of the document.  What is the best approach to conditionally skip the page break on the first or last page, or in some other way not have a blank page leading or trailing?

Additionally, for my initial sample, I want to have pages that are mostly composed of Word drawing elements (text boxes, lines, etc.), and doesn't really need to have (or should have, really) any regular text outside of the drawing elements.  I mention this in case that might influence someone's answer one way or the other.

Thanks -- looking forward to incorporating TBS into my future projects and really want to make this work well.
By: Skrol29
Date: 2012-02-08
Time: 12:19

Re: OpenTBS: page breaks / one page per record

Merging one page per record is quite possible.

In the example provided with the OpenTBS package, you have a tip:
***********
If you try to merge one page per record without text before the first page, then you may have an unsightly page-break at the beginning of your merged document. If it does so, then first check that the page-break is made thought the properties of the paragraph, and not using a manually inserted page-break. Then make sure the first page of your template contains only one paragraph which includes the following TBS tag.
***********

So, the basic principle for merging one page per record without a blank page, is to use the synopsis below:


<paragraph>
  [b;block=begin;comm=w:p] (put this tag in a separate paragraph, before the page-break)
</paragraph>

<paragraph with "page-break before" as a property>
  Here, put the content of the page on one or more paragraphs.
</paragraph>

<paragraph>
  [b;block=end;comm=w:p] (put this tag in a separate paragraph, at the end of the page)
</paragraph>


If your page has only drawings, then locate the drawing relatively to paragraph with the "page-break before".
This can be done in the "Format Drawing Canvas" property window, choose tab "Layout".

You must be sure that there is absolutely nothing before the paragraph with [b;block=begin;comm=w:p].

If this doesn't help, then you can send to me a template and I'll check what is going wrong.

By: John Lawler
Date: 2012-02-09
Time: 23:43

Re: OpenTBS: page breaks / one page per record

Skrol, thank you much for your quick reply that helped me to fix my problem.

I had actually reviewed demo_ms_word.docx, and was attempting to duplicate what was going on at the very bottom of that template, to repeat the final page, but had missed the subtleties of the page break before situation and needing the extra two paragraphs.

Thank you for the extra point about anchoring my drawing elements to the 2nd paragraph.  If they get anchored to the other paragraphs, they don't render in the output.