OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Dynamically creating an FO table based on content length


Hi all,

I have a problem which I can't think of a good way to solve.  I realize that I am perhaps approaching this problem incorrectly, so I hope someone can point me in the right direction.

Suppose that I have an arbitrary series of paragraphs in my source file, containing an arbitrary amount of content:

<para>This is some content.</para>
<para>This is more content.</para>
<para>This is even more content.</para>
<para>This is a longer amount of content.</para>

Now, suppose that I want to format this source in an FO table with a single row of cells.  I want the table to have a fixed height--say, 2 inches--so that the table never grows higher  than 2 inches.  I might do this by placing block-containers within the table cells, giving them height attributes.  Then, I distribute my content among the table cells accordingly:

<fo:table>
  <fo:table-column column-number="1"/>
  <fo:table-column column-number="2"/>

  <fo:table-body>
    <fo:table-row>
      <fo:table-cell>
        <fo:block-container height="2in">
          <fo:block>This is some content.</fo:block>
          <fo:block>This is more content.</fo:block>
          <fo:block>This is even more content.</fo:block>
        </fo:block-container>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block-container height="2in">
          <fo:block>This is a longer amount of content.</fo:block>
        </fo:block-container>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>

The problem, however, is that the source file can contain any number of paragraphs of various lengths, and this will not be known until processing time.  Since I never want my table exceed 2 inches in height, I may need to add more columns as needed to get additional cells.  The idea here is that the first cell will accommodate 2-inches-worth of content, then whatever overflows will spill into the next cell, which will in turn accommodate 2 inches of content, etc., and this will continue until all content is displayed.

I'd like a stylesheet to automatically handle this.  It will determine how much content there is, how many table columns are needed, and distribute the content accordingly.  However, this seems rather difficult to do, since the stylesheet has no way of knowing what the final print output will look like, how large the fonts will be, etc.

I might be able to do something with string lengths.  Calculate the length of each paragraph, calculate the capacity of a table cell, and output the paragraphs in table cells where they fit.  But this would be based on character counts only, which hold no bearing on the final print output when a variable-width font is used; i.e., if the string "abcde" has a length of "5", that doesn't tell me anything about how much physical space the text "abcde" will occupy when printed in Helvetica font at size 12pt.

Does what I'm getting at make sense?  I hope I am being clear about my problem; let me know if I am not.

Thanks,
Colin


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]