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:
<?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.
| 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:
<?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:
<?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
marginspecified in the<fo:simple-page-master>tag creates the white area. - The
marginspecified in the<fo:region-body>tag forces the region-body edges in one inch from the simple-page-master rectangle. - The
paddingspecified 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:
<?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.
XSL-FO Page Layout的更多相关文章
- 在Salesforce中向Page Layout中添加Visualforce Page
在Salesforce中可以向Object所对应的Layout中添加我们自定义的Visualforce Page. 此时的Visualforce Page与Asp.Net MVC中的Partial V ...
- 转载 SharePoint 2013配置Master Page and Page Layout
转载原地址: http://www.cnblogs.com/huangjianwu/p/4539706.html 涉及到的内容是关于SharePoint 2013如何部署自定义的母版页和布局页. 进入 ...
- salesforce零基础学习(八十四)配置篇: 自定义你的home page layout
当我们进入salesforce系统或者切换app后,默认第一个看到的就是home页面.home页面简单的来说可以包括左侧(narrow component)和右侧(wide component)两部分 ...
- SharePoint 2013 Deploy Master Page And Page Layout
2013年9月27日的一篇随笔,其实也是自己编写的部署文档,由于客户是HK的,所以描述部分是用英文. 涉及到的内容是关于SharePoint 2013如何部署自定义的母版页和布局页. First, L ...
- Creating a Custom Page Layout in SharePoint 2013
Creating a Custom Page Layout in SharePoint 2013 In my last article, I documented how to create a Ma ...
- Page Layout里的javascript (jquery)不执行
在page layout 中通过 _spBodyOnLoadFunctionNames.push("js 方法名") 的方式实现. 但切记,代码要放到 PlaceHolderMai ...
- salesforce零基础学习(九十四)classic下pagelayout引入的vf page弹出内容更新此page layout
我们在classic环境中,有时针对page layout不能实现的地方,可以引入 一个vf page去增强标准的 page layout 功能,有时可能要求这个 vf page的部分修改需要更新此 ...
- xsl -fo 了解
XSL-FO是用于格式化XML数据的语言,全称为Extensible Stylesheet Language Formatting Objects(格式化对象的可扩展样式表语言),是W3C参考标准,现 ...
- 【CSS】Intermediate8:Page Layout
1.Layout with CSS is easy. You just take a chunk of your page and shove it wherever you choose 2.pos ...
随机推荐
- ASP.NET MVC:创建 ModelBinder 自动 Trim 所有字符串
ASP.NET MVC:创建 ModelBinder 自动 Trim 所有字符串 2010-12-29 21:32 by 鹤冲天, 4289 阅读, 14 评论, 收藏, 编辑 用户输入的字符串前后的 ...
- TFTP 与 FTP的区别
FTP(File Transfer Protocol,文件传输协议)协议在TCP/IP协议族中属于应用层协议,用于在远端服务器和本地客户端之间传输文件,使用TCP端口20和21进行传输.端口20用于传 ...
- 几段表单处理的JQuery代码(转)
1 只接受数字输入 $("#uAge").keydown(function(event) { // 允许退格和删除键 if ( event.keyCode == 46 || eve ...
- Atitit.变量的定义 获取 储存 物理结构 基本类型简化 隐式转换 类型推导 与底层原理 attilaxDSL
Atitit.变量的定义 获取 储存 物理结构 基本类型简化 隐式转换 类型推导 与底层原理 attilaxDSL 1.1. $ 美元字符, php 黑头1 1.2. 默认变量的范围和声明:1 1.3 ...
- 字符串函数---strcmp()与strncmp()具体解释及实现
一.strcmp()与strncmp() strcmp():strcmp(s1,s2); 比較两个字符串. strncmp():strncmp(s1,s2); ...
- GroupCoordinator joingroup源码解析
转发请注明原创地址 http://www.cnblogs.com/dongxiao-yang/p/7463693.html kafka新版consumer所有的group管理工作在服务端都由Group ...
- 没有局域网环境,全是公网IP可以做LVS吗,该如何做了!请大家赐教!
没有局域网环境,全是公网IP可以做LVS吗,该如何做了!请大家赐教! 由 wjjava 在 周四, -- : 提交 LVS集群 现在有3台服务器,各有一个公网IP地址.IP地址形式如下: IP1:12 ...
- java继承机制
1 继承 关键字:extends java没有多重继承 实例 父类: package unit4; public class Base { public int publicVarofBase= ...
- java 无状态和有状态区别
诸位Java程序员,想必大家对SimpleDateFormat并不陌生.不过,你是否知道,SimpleDateFormat不是线程安全的(thread safe).这意味着,下面的代码是错误的: ...
- hadoop_百科
一.发音是:[hædu:p]. 二.简介:Hadoop是一个由Apache基金会所开发的分布式系统基础架构.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力进行高速运算和存储 ...