XSL-FO Page Layout

Simple Layout

Let‘s take a look at the simple page layout that we saw earlier in the course.

The simple page master that creates this layout is shown in the code sample below.

Code Sample:

PageLayout/Demos/SimplePageMaster.fo

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page"
			page-height="11in" page-width="8.5in">
			<fo:region-body margin="1in" background-color="yellow"
				border="solid thick orange"/>
			<fo:region-before extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-after extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-start extent="1in" background-color="lightgreen"
				border="solid thick green"/>
			<fo:region-end extent="1in" background-color="lightgreen"
				border="solid thick green"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="24pt"
		font-weight="bold" text-align="center">
---- C O D E   O M I T T E D ----
</fo:page-sequence>
</fo:root>

  

fo:simple-page-master

The fo:simple-page-master is used to specify the name of the master page, the height and width of the page, the margins of the entire page and the orientation of the page (e.g, portrait or landscape). Its most common attributes are shown below.

<fo:simple-page-master> Attributes
Attribute Description
master-name the name of the master page
page-height the height of the page
page-width the width of the page
margin the size of the margin around the entire page
margin-top the size of the top margin
margin-right the size of the right margin
margin-bottom the size of the bottom margin
margin-left the size of the left margin
reference-orientation sets the direction for page

Most of these attributes are self explanatory. However, we should take a closer look at reference-orientation.

Reference Orientation

The reference-orientation attribute takes a number which indicates the number of degrees to rotate the orientation. Possible values are 0, 90, 180, 270, -90, -180, -270, and inherit. To create a landscape orientation, reference-orientation should be set to 90. The following example illustrates this.

Code Sample:

PageLayout/Demos/LandscapePageMaster.fo

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page"
			page-height="11in" page-width="8.5in"
			reference-orientation="90">
			<fo:region-body margin="1in" background-color="yellow"
				border="solid thick orange"/>
			<fo:region-before extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-after extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-start extent="1in" background-color="lightgreen"
				border="solid thick green"/>
			<fo:region-end extent="1in" background-color="lightgreen"
				border="solid thick green"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="24pt"
		font-weight="bold" text-align="center">
---- C O D E   O M I T T E D ----
</fo:page-sequence>
</fo:root>

  

The only difference between this page and the previous one is the reference orientation. The result is shown below.

Notice that the whole page shifts, so that the region-before is now on the left rather than on the top.

fo:region-body

The <fo:region-body> tag is used to define the space, background and borders for the region-body. Its most common attributes are shown below.

Most of these attributes are self explanatory. We‘ll take a closer look at margin and padding.

margins and padding

We saw that the <fo:simple-page-master> tag can take margin attributes. These margins are applied to the whole page, meaning that they push all the regions inward. The margin attributes of the <fo:region-body> tag affect only region-body. They specify how far each edge of the region-body box should be from the edge of the outer box defined by the <fo:simple-page-master> tag. The padding attributes specify how far the elements contained in the body should appear from the edge of the body. The following code sample illustrates how margin and padding work.

Code Sample:

PageLayout/Demos/BodyRegionPageMaster.fo

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page"
			page-height="11in" page-width="8.5in"
			margin="1in">
			<fo:region-body margin="1in" padding="1in"
				background-color="yellow" border="solid thick orange"/>
			<fo:region-before extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-after extent="1in" background-color="lightblue"
				border="solid thick blue"/>
			<fo:region-start extent="1in" background-color="lightgreen"
				border="solid thick green"/>
			<fo:region-end extent="1in" background-color="lightgreen"
				border="solid thick green"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="24pt"
		font-weight="bold" text-align="center">
---- C O D E   O M I T T E D ----
</fo:page-sequence>
</fo:root>

  

The result is shown below.

  • The margin specified in the <fo:simple-page-master> tag creates the white area.
  • The margin specified in the <fo:region-body> tag forces the region-body edges in one inch from the simple-page-master rectangle.
  • The padding specified in the <fo:region-body> tag creates space between the content of the region-body and the edges of the region-body.

Note that the positioning and size of region-body are not affected in any way by the attributes of the other regions.

fo:region-before, fo:region-after, fo:region-start, and fo:region-end

The four other region tags take all the same attributes as <fo:region-body> except for the margin attributes. These regions do not have margins. They always sit on the edge of the simple-page-master rectangle. In addition, these region tags take two other attributes: extent and precedence.

The extent attribute specifies the width of region-start and region-end and the height of region-before and region-after (assuming a portrait layout).

The precedence attribute specifies which regions should sit on top. As you can see from the examples we have looked at thus far, by default region-start and region-end take precedence over region-before and region-after. The following code sample shows how to change this.

Code Sample:

PageLayout/Demos/PrecedencePageMaster.fo

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page"
			page-height="11in" page-width="8.5in"
			margin="1in">
			<fo:region-body margin="1in" padding="1in"
				background-color="yellow" border="solid thick orange"/>
			<fo:region-before extent="1in" precedence="true"
				background-color="lightblue" border="solid thick blue"/>
			<fo:region-after extent="1in" precedence="true"
				background-color="lightblue" border="solid thick blue"/>
			<fo:region-start extent="1in" background-color="lightgreen"
				border="solid thick green"/>
			<fo:region-end extent="1in" background-color="lightgreen"
				border="solid thick green"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="24pt"
		font-weight="bold" text-align="center">
---- C O D E   O M I T T E D ----
</fo:page-sequence>
</fo:root>

  

The result is shown below. As you can see, region-before and region-after now sit on top of region-start and region-end.

时间: 2024-10-11 04:07:58

XSL-FO Page Layout的相关文章

xsl -fo 了解

XSL-FO是用于格式化XML数据的语言,全称为Extensible Stylesheet Language Formatting Objects(格式化对象的可扩展样式表语言),是W3C参考标准,现在通常叫做XSL. 什么是 XSL-FO XSL-FO 是用于格式化 XML 数据的语言 XSL-FO 指可扩展样式表语言格式化对象(Extensible Stylesheet Language Formatting Objects) XSL-FO 是一个 W3C 推荐标准 XSL-FO 目前通常被

SharePoint 2013 Deploy Master Page And Page Layout

2013年9月27日的一篇随笔,其实也是自己编写的部署文档,由于客户是HK的,所以描述部分是用英文. 涉及到的内容是关于SharePoint 2013如何部署自定义的母版页和布局页. First, Login to site collection by site collection administrator, and we should click the menu of "Site collection features" in "Site Collection Adm

how to add Javascript and CSS in page layout with sharepoint 2013

how to add Javascript and CSS in page layout with sharepoint 2013 Sometimes, we need create a custom page layout, at the time, if we want to add some javascript and css code, how to do it? we cannot add the code in page layout file directly, the syet

salesforce零基础学习(八十四)配置篇: 自定义你的home page layout

当我们进入salesforce系统或者切换app后,默认第一个看到的就是home页面.home页面简单的来说可以包括左侧(narrow component)和右侧(wide component)两部分. 左侧包含Recent View,Custom Link,Create New等快捷入口等组件,右侧包括tasks,item to approval,calendar,dashboard snapshot等等. 有时,不同简档的用户需要看到不同的Home页面中的组件或者显示不同的custom li

12.1.2: How to Modify and Enable The Configurable Home Page Delivered Via 12.1.2 (Doc ID 1061482.1)

In this Document   Goal Solution References       APPLIES TO:    Oracle Applications Framework - Version 12.1.2 to 12.1.2 [Release 12.1] Information in this document applies to any platform. Checked for relevance on 18-JAN-2014   GOAL   This document

Enhance Magento 404 page

Magento default installation already has a predefined custom 404 page (no-route). But is it enough to help visitor/customer get back on right track!? . Let's look over a few examples of custom designed 404 pages. http://centar-alata.hr/404, https://g

Xamarin.Forms Layout Challenges – Great Places(已全文翻译)

原文地址:https://www.kymphillpotts.com/xamarin-forms-layout-challenges-great-places/ (作者Kym Phillpotts) 项目Github地址:https://github.com/kphillpotts/XamarinFormsLayoutChallenges When your app is all about the images, sometimes you want your images to be her

EDAS: the gutter between columns is 0.16 inches wide (on page 2), but should be at least 0.2 inches.

Submit a manuscript through EDAS and I am using the IEEEtran class (conference option). EDAS gives the following errors: Solutions: 1. May be caused by figures or tables which cross two columns. Before modification: \begin{figure*}[ht] \begin{center}

『ENGLISH』

以A字母开头的词汇 英文 中文 abstract module 抽象模组 access 访问.存取 access control 存取控制 access control information 存取控制资讯 access mechanism 存取机制 access rights 存取权限 accessibility 无障碍性 accessibility information 无障碍网页资讯 accessibility problem 无障碍网页问题 accessible 无障碍的 access