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: RE: [docbook-apps] Dynamically creating an FO table based on content length


Title: Message
It seems that you could force that list to a multi-column block? Still, that would be a significant customization.
 
Regards,

Dean Nelson   
Enterprise Electronics Corp

-----Original Message-----
From: Colin Shapiro [mailto:cmshapiro@gmail.com]
Sent: Tuesday, April 03, 2007 3:29 PM
To: Nelson, Dean
Cc: docbook-apps@lists.oasis-open.org
Subject: Re: [docbook-apps] Dynamically creating an FO table based on content length

Hi,

Yes, this is similar to what I am trying to do.  However, I don't believe that this is a DocBook-specific problem, or a shortcoming of the DocBook DTD / XSL distribution itself.

I could be using my own custom DTD and I still wouldn't know how to write XSLT that can predict the physical dimensions of printed text blocks after they are generated by an FO processor.  That is the heart of my question.

Obviously, there is no way a stylesheet can know exactly what printed output will look like, since the FO processor has yet to do its magic.  But maybe there's a good way to predict the output, somehow.

If you wanted to go all-out, you could probably do the following:

1) Based on the font family, size, weight, and style that will be used, calculate the final, printed widths of each possible character (or at least letters/numbers) and store them in variables.
2) Use these values to calculate the total widths of the paragraphs/listitems/whatever you want to output.
3) Use these total widths to calculate how many lines each paragraph/listitem/whatever needs to occupy.
4) Use this information to determine how many columns are needed to contain all the lines of text produced.

That, however, seems like a lot of work, and a very complicated stylesheet.

Is there a better way?

Colin

On 4/3/07, Nelson, Dean <dean.nelson@eecradar.com> wrote:
This was something that I was wondering myself, just yesterday. I wanted to be able to do a list that had a certain height and would automatically wrap to the next column on the right when the height was exceeded. But atlas, this mere mortal failed and could not figure out how to do it with standard Docbook features.
 
I think that this is a feature that could be added to the lists in Docbook?

Regards,

Dean Nelson   
Enterprise Electronics Corp

-----Original Message-----
From: Colin Shapiro [mailto:cmshapiro@gmail.com]
Sent: Tuesday, April 03, 2007 2:14 PM
To: docbook-apps@lists.oasis-open.org
Subject: [docbook-apps] 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]