PDF模板中的数字页面
此示例显示了如何使用PDF模板编号报告的编号页。它通过使用两个不同的页脚为奇数页定义了一个右页的右页码和一个均匀的页码。下图在使用示例模板创建的文档中显示了两个页面:
创建一个模板
创建一个PDF模板,myPDFTemplate.pdftx
,,,,in the current working directory. Unzip the template for editing. A reference template that already includes the footers for the example is available inevempletemplate。pdftx
。
mlreportgen.dom.document.CreateTemplate(“ mypdftemplate”,,,,“ PDF”);unziptemplate("myPDFTemplate.pdftx",,,,“ mypdftemplate_pdftx”);%unziptemplate(“ exigpletemplate.pdftxt”,“ exvetemplate_pdftx”);
定义页脚内容
在myPDFTemplate_pdftx\docpart_templates.html
,,,,define template parts that hold the content of the footers. In the
标签,创建
命名的元素mypagefooter
对于奇数页和Myevenfooter
为了甚至页s. Create paragraphs that contain the text included in each footer as well as页
应放置页码的元素。设置文本一致
风格正确的
为了mypagefooter
and剩下
为了Myevenfooter
。例如:
。 > > > -of-levels =“ 3” Leader-pattern =“ dots” /> < /dptemplate> <! - 文档零件模板定义页脚 - > page
page
创建页脚元素
在身体部分mypdftemplate_pdftx \ root.html
,摘要<布局>
元素并添加两个
元素。设置类型
and模板名称
属性如下示例HTML代码所示。这默认
Type页脚用于第一页和奇数页。这甚至
类型的页脚用于均匀的页面。这模板名称
attributes are set to the names of the template parts defined earlier. To specify the number of the starting page, add a
元素。
report> report> reportrel =“ stylesheet” href =“ ./ stylesheets/root.css” type =“ text/css”/> > > <! - uncommunt并编辑此布局以自定义基于文档或文档的布局在此模板上。- >
Zip the Template
将模板文件缩回myPDFTemplate.pdftx
template package.
Ziptemplate('mypdftemplate.pdftx',,,,'myPDFTemplate_pdftx');
使用模板
Use the template by specifying the template name when creating the document. The following code uses the reference templateevempletemplate。pdftx
创建文档。要使用示例修改的模板,请替换evempletemplate
和myPDFTemplate
。
进口mlreportgen.dom。*d =文档("myDocument",,,,“ PDF”,,,,“ evempletemplate”);打开(d);附加(d,“你好世界”);附加(d,pagebrak());附加(d,“再一次问好”);附加(d,pagebrak());附加(d,“再一次问好”);附加(d,pagebrak());附加(d,“再一次问好”);附加(d,pagebrak());附加(d,“再一次问好”);close(d); rptview(d);