Fixed Position Output

1. Fixed position output
2. Summary at the bottom of the page
3. Forms, and XSL-FO
4. Drop caps
5. Superimposition in XSL-FO
6. position property; relative and absolute
7. Superimposition in XSL-FO
8. Aligment of floats.

1.

Fixed position output

G. Ken Holman

>The symptom is that the manager block appears at different places depending
>on how many items the agenda has. If there is just a few, the manager is
>near the middle of the page, and if there's plenty it may appear at a second
>page!
>
>What I want to do is to be able to relate the manager block to the bottom of
>the page instead of to the above block. Is this possible?

How about using an absolute or fixed positioned block-container object?

I've attached a three-page example below where the manager appears in the same position on each page regardless of the length of the flow. I've set the top edge of the container to the same position on each page. Note that I also used a single page page-sequence so that if the agenda flowed to the second page the rendering agent would report an overflow of the page-sequence.

<?xml version="1.0" encoding="utf-8"?><!--gustaf.fo-->
<root xmlns="http://www.w3.org/1999/XSL/Format"
       font-family="Times" font-size="25pt">

<layout-master-set>
   <simple-page-master master-name="frame"
     page-height="297mm" page-width="210mm"
     margin-top="15mm" margin-bottom="15mm"
     margin-left="15mm" margin-right="15mm">
     <region-body region-name="frame-body"
       border="dotted"
       margin-top="13mm" margin-bottom="13mm"/>
   </simple-page-master>
   <page-sequence-master master-name="frame-one-page-only">
     <single-page-master-reference master-name="frame"/>
   </page-sequence-master>
</layout-master-set>

<page-sequence master-name="frame-one-page-only">
   <flow flow-name="frame-body" text-align="center">

     <block space-before="1cm">This is to certify:</block>

     <block font-style="italic" font-size="50pt"
            space-before="3cm">Gustaf</block>

     <block space-before="3cm"
            space-after="1cm">Has completed:</block>

     <block>Agenda 1</block>
     <block>Agenda 2</block>
     <block>Agenda 3</block>
     <block>Agenda 4</block>
     <block>Agenda 5</block>

     <block-container absolute-position="fixed"
                      top="220mm">
       <block>Manager:
         <inline font-style="italic">wife</inline>
       </block>
     </block-container>
   </flow>
</page-sequence>

<page-sequence master-name="frame-one-page-only">
   <flow flow-name="frame-body" text-align="center">

     <block space-before="1cm">This is to certify:</block>

     <block font-style="italic" font-size="50pt"
            space-before="3cm">Gustaf</block>

     <block space-before="3cm"
            space-after="1cm">Has completed:</block>

     <block>Agenda 1</block>
     <block>Agenda 2</block>

     <block-container absolute-position="fixed"
                      top="220mm">
       <block>Manager:
         <inline font-style="italic">wife</inline>
       </block>
     </block-container>
   </flow>
</page-sequence>

<page-sequence master-name="frame-one-page-only">
   <flow flow-name="frame-body" text-align="center">

     <block space-before="1cm">This is to certify:</block>

     <block font-style="italic" font-size="50pt"
            space-before="3cm">Gustaf</block>

     <block space-before="3cm"
            space-after="1cm">Has completed:</block>

     <block>Agenda 1</block>
     <block>Agenda 2</block>
     <block>Agenda 3</block>
     <block>Agenda 4</block>


     <block-container absolute-position="fixed"
                      top="220mm">
       <block>Manager:
         <inline font-style="italic">wife</inline>
       </block>
     </block-container>
   </flow>
</page-sequence>

</root>

2.

Summary at the bottom of the page

Ken Holman



>I've 2 block-container inside my region-body. The first block-container is 
>a table with n-rows inside. The 2nd block is
>a summaryblock and should reside always on the bottom of the page, if 
>possible on the first page but only if there are
>not too many rows inside the first block. How can i do that.

You can put the second block into a footnote and introduce an empty block after your first block with an empty footnote citation inline and your second block into the footnote body.

Remember (and I sound like a broken record here) ... don't get hung up on the names of the constructs. These are layout constructs you can use to achieve the desired layout regardless of the source of the information being laid out. Even though you aren't working with footnotes, your comment "should reside always on the bottom of the page" should bring to mind that the footnote construct is a construct that performs this particular kind of layout.

Of course the caveat in this case is that if you also have footnotes then I think you are out of luck.

3.

Forms, and XSL-FO

Eliot Kimber



> Has anyone ever attempted to print tax forms (i.e. 1099, 1098, W-2) using 
> XSL-FO.  I'm wondering if using 'fo:external graphic' would work for 
> printing the form itself in the 'background' (printing the data for these 
> forms has already been accomplished using XSL-FO). 

There are at least these techniques you could use:

1. Use overlapping absolutely-positioned block-containers, one with the form, one with the data
2. Put the form in an edge region that has an extent that overlaps the region-body
3. Use a background graphic with the form

Option 2 is probably the most portable, with 3 the second most.

You could use fo:table to construct the form itself, unless you already have a graphic rendering of the form. With XEP and XSL Formatter you could use SVG to draw the form.

4.

Drop caps

W. Eliot Kimber

I've always done drop caps with side floats:

       <fo:block
         font-size="12pt"
         font-family="sans-serif"
         line-height="1em"
       >
         <fo:float float="start">
           <fo:block
               font-size="72pt"
               font-family="serif"
               line-height="1em"
               padding-end="24pt"
               >H</fo:block>
         </fo:float>
         <fo:inline>ere is the start of the paragraph.
         And this is more content in the paragraph.
         And more. And more. And this is more content in the paragraph.
         And more. And more. And this is more content in the paragraph.
         And more. And more. And this is more content in the paragraph.
         And more. And more. </fo:inline>
       </fo:block>

This may require jiggering of the details of edge margins, padding, etc., as different implementations are likely to vary in their behavior at the level of precise character placement.

Side floats are the only construct that provide any form of runaround in XSL-FO 1.0.

5.

Superimposition in XSL-FO

W. Eliot Kimber



>>  If you don't use relative-position, how would you 
>> position one block over another, for instance if you wanted to 
>> position some text over an image, and you wanted this to occur in the 
>> normal flow on a page ?

My normal practice is to use two absolute-positioned block containers within another normally-positioned block container with relative-position="static". That is, the root block container establishes a new reference area and the two child block containers are then absolutely positioned with respect to their containing reference area (which is itself in the normal flow of blocks).

Here's my test, which gives the same results with XSL Formatter 2.5 and XEP 3.77:

         <fo:block
             font-family="sans-serif"
             font-size="24pt"
             line-height="110%"
             space-before="12pt"
           >Test of overlayed blocks using nested absolutely-positioned
block containers.
         </fo:block>
         <fo:block-container
               relative-position="static"
               absolute-position="auto"
               text-align="center"
               display-align="center"
               background-color="gray"
               inline-progression-dimension="2.5in"
               block-progression-dimension="2.5in"
         >
           <fo:block-container absolute-position="absolute"
               left="0pt"
               top="0pt"
               z-index="1"
               background-color="yellow"
               inline-progression-dimension="2in"
               block-progression-dimension="2in"
               border-style="solid"
               border-width="0.5pt"
               border-color="blue"
               ><fo:block>This is within a block container with z-index
"1"</fo:block>
           </fo:block-container>
           <fo:block-container absolute-position="absolute"
               left="0.5in"
               top="0.5in"
               z-index="2"
               background-color="silver"
               inline-progression-dimension="1in"
               block-progression-dimension="1in"
               border-style="solid"
               border-width="0.5pt"
               border-color="green"
               ><fo:block>This is within a block container with z-index
  "2"</fo:block>
           </fo:block-container>
         </fo:block-container>
         <fo:block
             font-family="serif"
             font-size="26pt"
             line-height="110%"
             space-before="12pt"
             start-indent="0.5in">This is after the block
containers.</fo:block>
     </fo:flow>

6.

position property; relative and absolute

W. Eliot Kimber



>> position= isn't an FO property (probably meant absolute-position=) 
>> but in any case only block-container can be absolutely positioned.


> It's a shorthand (sect. 7.29.20). 

Ah, I hadn't noticed this shorthand. But it is a shorthand that maps to either absolute-position or relative-position. As absolute-position only applies to block-container and relative-position explicitly does not apply to block-container, this must mean that position maps to relative-position when used on fo:block.


> I can't find the restriction that
> only block-containers may be absolutely positioned in the spec, can 
> you help me here?

The absolute-position property only applies to block-container. Section 7.5.1.

However, reading the description relative-position I'm not 100% clear what it means for blocks. My initial reading is that it has no effect but I also grant that the description is confusing at best.

Doing an experiment with XEP 3.77 and XSL Formatter 2.5 it appears that relative-position has no effect on blocks. My test instance is below. The first two blocks format the same with XSL Formatter. With XEP, the second block is only 2in wide (the 1.0 spec is ambiguous about whether width= is meaningful on fo:block). The second two blocks are formatted with identical positioning by both formatters.

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="mypage"
         page-height="11in"
         page-width="8.5in">
       <fo:region-body
           margin-left="20pt"
           margin-right="20pt"
           margin-top="20pt"
           margin-bottom="20pt"
           border-width="0.5pt"
           border-color="blue"
           border-style="solid"
       />
     </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="mypage">
     <fo:flow flow-name="xsl-region-body"
         font-family="sans-serif">
       <fo:block
         >Test of relative-position on blocks.</fo:block>
       <fo:block left="10pt"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
       >Block with left=10pt</fo:block>

       <fo:block
           left="1in"
           width="2in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="relative"
       >Block with width=2in left=1in and
relative-position="relative"</fo:block>
       <fo:block
           left="1in"
           width="2in"
           margin-left="0.5in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="relative"
       >Block with width=2in left=1in margin-start="0.5in" and
relative-position="relative"</fo:block>
       <fo:block
           left="1in"
           width="2in"
           margin-left="0.5in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="static"
       >Block with width=2in left=1in margin-start="0.5in" and
relative-position="static"</fo:block>
     </fo:flow>
   </fo:page-sequence>
</fo:root>

7.

Superimposition in XSL-FO

W. Eliot Kimber



>>  If you don't use relative-position, how would you 
>> position one block over another, for instance if you wanted to 
>> position some text over an image, and you wanted this to occur in the 
>> normal flow on a page ?

My normal practice is to use two absolute-positioned block containers within another normally-positioned block container with relative-position="static". That is, the root block container establishes a new reference area and the two child block containers are then absolutely positioned with respect to their containing reference area (which is itself in the normal flow of blocks).

Here's my test, which gives the same results with XSL Formatter 2.5 and XEP 3.77:

         <fo:block
             font-family="sans-serif"
             font-size="24pt"
             line-height="110%"
             space-before="12pt"
           >Test of overlayed blocks using nested absolutely-positioned
block containers.
         </fo:block>
         <fo:block-container
               relative-position="static"
               absolute-position="auto"
               text-align="center"
               display-align="center"
               background-color="gray"
               inline-progression-dimension="2.5in"
               block-progression-dimension="2.5in"
         >
           <fo:block-container absolute-position="absolute"
               left="0pt"
               top="0pt"
               z-index="1"
               background-color="yellow"
               inline-progression-dimension="2in"
               block-progression-dimension="2in"
               border-style="solid"
               border-width="0.5pt"
               border-color="blue"
               ><fo:block>This is within a block container with z-index
"1"</fo:block>
           </fo:block-container>
           <fo:block-container absolute-position="absolute"
               left="0.5in"
               top="0.5in"
               z-index="2"
               background-color="silver"
               inline-progression-dimension="1in"
               block-progression-dimension="1in"
               border-style="solid"
               border-width="0.5pt"
               border-color="green"
               ><fo:block>This is within a block container with z-index
  "2"</fo:block>
           </fo:block-container>
         </fo:block-container>
         <fo:block
             font-family="serif"
             font-size="26pt"
             line-height="110%"
             space-before="12pt"
             start-indent="0.5in">This is after the block
containers.</fo:block>
     </fo:flow>

8.

Aligment of floats.

Alexander Peshkov


> Is there a way using fo:float to display marginalia with 
>a text-alignment of
> "left" or "right", depending on which page they occur?
> The marginalia on an odd page should have a text-alignment of left, and the
> marginalia on an even page should have a text-alignment of right.

XEP support special values for both 'text-align' and 'float' properties: "inside" and "outside". Using these values you can achieve desired effect.