XSL-FO Tutoriallogin
XSL-FO Tutorial
author:php.cn  update time:2022-04-21 16:29:33

XSL-FO block



The output of XSL-FO is in the block area.


XSL-FO Page, Flow and Block

The content "block" will "flow" into the "page" and then be output to the media .

XSL-FO output is typically nested within <fo:block> elements, <fo:block> is nested within <fo:flow> elements, <fo:flow> is nested within Within the <fo:page-sequence> element:

<fo:page-sequence>
​ <fo:flow flow-name="xsl-region-body">
​​ <fo:block>
                          <!-- Output goes here -->
​​ </fo:block>
​ </fo:flow>
</fo:page-sequence>


Attributes of the block area

The block is located in a rectangular box The output sequence:

<fo:block border-width="1mm">
This block of output will have a one millimeter border around it.
</fo:block>

Because the block area is a rectangular box, it can share many common area attributes:

  • space before and space after

  • margin

  • border

  • padding

img_boxmodel.gif

space before and space after are spaces that separate blocks.

margin is the white space outside the block.

border is the rectangle at the outer edge of the area. Each of its four sides can have different widths. It can also be filled with different colors and background images.

padding is the area between the border and content areas.

content The area can contain actual content, such as text, pictures, graphics, etc.


Block Margin

  • margin

  • margin-top

  • margin-bottom

  • margin-left

  • ##margin-right


Block Border

Border style attributes:

  • border-style

  • border-before -style

  • border-after-style

  • border-start-style

  • border- end-style

  • border-top-style (equivalent to border-before)

  • border-bottom-style (equivalent to border-after )

  • border-left-style (equivalent to border-start)

  • ##border-right-style (equivalent to border-end)
  • Border color attribute:

    border-color
  • border-before-color
  • border-after-color
  • border-start-color
  • border-end-color
  • border-top-color (equivalent to border-before)
  • border-bottom-color (equivalent to border-after)
  • border-left-color (equivalent to border-start)
  • border-right-color (equivalent to border-end)
  • Border width attribute:

    border-width
  • border-before-width
  • border-after-width
  • border-start-width
  • border-end-width
  • border-top-width (equivalent to border-before)
  • border-bottom-width (equivalent to border-after)
  • border-left-width (equivalent to border-start)
  • border-right-width (equivalent to border-end)
Block Padding

    padding
  • padding-before
  • padding-after
  • padding-start
  • padding-end
  • padding-top (equivalent to (equal to padding-before)
  • padding-bottom (equal to padding-after)
  • padding-left (equal to padding-start)
  • padding-right (equivalent to padding-end)
Block Background

    background-color
  • background-image
  • background-repeat
  • background -attachment (scroll or fixed)
Block Styling Attributes

Blocks are output sequences that can be individually styled:

<fo:block font-size="12pt" font-family="sans-serif">
This block of output will be written in a 12pt sans-serif font.
</fo:block>

Font properties:

  • font -family

  • font-weight

  • font-style

  • font-size

  • font-variant

Text attributes:

  • text-align

  • text-align-last

  • text-indent

  • start-indent

  • end-indent

  • wrap-option (define automatic line wrapping)

  • break-before (define page break)

  • break-after (define page break)

  • reference-orientation (define text rotation in 90" increments)


Example

<fo:block font-size="14pt" font-family="verdana" color="red"
space-before="5mm" space-after="5mm">
PHP.CN
</fo:block>

<fo:block text-indent="5mm" font-family="verdana" font-size="12pt">
At php.cn you will find all the Web-building tutorials you
need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.
</fo:block>

Result:

Normally, XSL-FO documents do not combine formatting information and content like we just did. With a little help from XSLT, we can put formatting information into the template and write purer content.

PHP.CN

At php.cn you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP. and paragraph documents, then a lot of code will be required.

You will learn how to use XSLT templates to compose XSL-FO later in this tutorial.