mlreportgen.dom.PageSize 类
命名空间: mlreportgen.dom
Microsoft Word 和 PDF 报 告中的页面大小和方向
描述
使用 mlreportgen.dom.PageSize
类的对象来指定 Microsoft® Word 或 PDF 报
告中页面的高度、宽度和方向。
mlreportgen.dom.PageSize
类是一个 handle
类。
创建对象
属性
Height
— 页面高度
'11in'
(默认) | 字符向量 | 字符串标量
页面高度,指定为字符向量或字符串标量,由数字和后跟计量单位的缩写组成。例如,'11in'
指定 11 英寸。有效的缩写是:
"px"
- 像素"cm"
- 厘米"in"
- 英寸"mm"
- 毫米"pc"
- 派卡"pt"
- 磅
Width
— 页面宽度
'8.5in'
(默认) | 字符向量 | 字符串标量
页面宽度,指定为字符向量或字符串标量,由数字和后跟计量单位的缩写组成。例如,'8.5in'
指定 8.5 英寸。有效的缩写是:
"px"
- 像素"cm"
- 厘米"in"
- 英寸"mm"
- 毫米"pc"
- 派卡"pt"
- 磅
Orientation
— 页面方向
'portrait'
(默认) | 'landscape'
页面方向,指定为以下字符向量或字符串标量之一:
'portrait'
表示垂直方向'landscape'
表示水平方向
Height
和 Width
属性确定页面方向,而不管 Orientation
属性的值如何。不过,最佳做法是将 Orientation
属性设置为与页面尺寸一致的值。如果高度大于宽度,则将 Orientation
设置为 'portrait'
。如果宽度大于高度,则将 Orientation
设置为 'landscape'
。
Tag
— mlreportgen.dom.PageSize
对象的标签
字符向量 | 字符串标量
mlreportgen.dom.PageSize
对象的标签,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标签。生成的标签形式为 CLASS:ID
,其中 CLASS
是对象类,ID
是对象的 Id
属性的值。指定您自己的标签值,以帮助您确定在文档生成过程中出现问题时要查找的位置。
属性:
NonCopyable | true |
数据类型: char
| string
Id
— mlreportgen.dom.PageSize
对象的标识符
字符向量 | 字符串标量
mlreportgen.dom.PageSize
对象的对象标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。您可以为 Id
指定自己的值。
属性:
NonCopyable | true |
数据类型: char
| string
示例
在 DOM 文档中指定页面大小和方向
使用 PageSize
对象指定文档的页面大小。在 PageSize
对象中,将 Orientation
属性设置为与 Height
和 Width
属性一致的值。
默认情况下,文档的页面高度为 11 英寸,宽度为 8.5 英寸,并且为纵向。您可以通过设置文档布局对象使用的 PageSize
对象的 Height
和 Width
属性来覆盖默认页面大小。例如指定 Height
为 "10in"
,Width
为 "8in"
,Orientation
为 "portrait"
。
import mlreportgen.dom.*; d = Document("myreport1","docx"); open(d); pageLayoutObj = d.CurrentPageLayout; pageLayoutObj.PageSize.Height = "10in"; pageLayoutObj.PageSize.Width = "8in"; pageLayoutObj.PageSize.Orientation = "portrait"; append(d,"This document has portrait pages"); close(d); rptview(d);
指定小于宽度的高度会使方向为横向,而不管 Orientation
属性的值如何。此示例指定高度为 8 英寸,宽度为 10 英寸。该示例将 Orientation
属性设置为 "landscape"
以与页面大小保持一致。
import mlreportgen.dom.*; d = Document("myreport2","docx"); open(d); pageLayoutObj = d.CurrentPageLayout; pageLayoutObj.PageSize.Height = "8in"; pageLayoutObj.PageSize.Width = "10in"; pageLayoutObj.PageSize.Orientation = "landscape"; append(d,"This document has landscape pages"); close(d); rptview(d);
您可以使用布局对象的 rotate
方法,而不是通过改变高度和宽度来更改页面方向。该方法切换 Height
和 Width
属性值,并将 Orientation
属性从 portrait
更改为 landscape
或将 landscape
更改为 portrait
。
import mlreportgen.dom.*; d = Document("myreport3","docx"); open(d); pageLayoutObj = d.CurrentPageLayout; pageLayoutObj.PageSize.Height = "10in"; pageLayoutObj.PageSize.Width = "8in"; pageLayoutObj.PageSize.Orientation = "portrait"; rotate(pageLayoutObj); append(d,"This document has landscape pages"); close(d); rptview(d);
在报告 API 报 告中指定页面大小和方向
使用 PageSize
对象指定报告或报告节的页面大小。在 PageSize
对象中,将 Orientation
属性设置为与 Height
和 Width
属性一致的值。
默认情况下,报告的页面高度为 11 英寸,宽度为 8.5 英寸。要覆盖报告的默认页面大小,请创建一个 PageSize
对象并将其分配给报告布局对象。要覆盖报告节的页面大小,请创建一个 PageSize
对象并将其分配给节报告器对象使用的布局对象。此示例指定报告的高度为 10 英寸,宽度为 8 英寸。标题页覆盖报告页面大小,报告的其余部分使用报告的页面大小。
import mlreportgen.report.*; import mlreportgen.dom.*; rpt = Report("myreport1","docx"); open(rpt); layoutObj = rpt.Layout; layoutObj.PageSize = PageSize("10in","8in","portrait"); tp = TitlePage("Title","Title Page"); tplayoutObj = tp.Layout; tplayoutObj.PageSize = PageSize("11in","9in","portrait"); append(rpt,tp); toc = TableOfContents; append(rpt,toc); ch = Chapter("My Chapter"); para = Paragraph("This chapter uses the report page size"); close(rpt); rptview(rpt);
报告的默认页面尺寸为纵向。要更改报告所有页面的方向,请使用报告布局对象的 Landscape
属性。此示例指定报告的所有页面均为横向。
import mlreportgen.report.*; import mlreportgen.dom.*; rpt = Report("myreport2","docx"); open(rpt); layoutObj = rpt.Layout; layoutObj.Landscape = true; tp = TitlePage("Title","Title Page","SubTitle","With Page Size and Orientation of Report"); append(rpt,tp); close(rpt); rptview(rpt);
要根据报告页面的方向更改节中页面的方向,请使用节布局对象的 Landscape
属性。在此示例中,报告具有默认尺寸,即高 11 英寸、宽 8.5 英寸,即纵向。该示例将标题页的方向更改为横向。
import mlreportgen.report.*; import mlreportgen.dom.*; rpt = Report("myreport3","docx"); open(rpt); tp = TitlePage("Title","Title Page","SubTitle","With Landscape Orientation"); tplayoutObj = tp.Layout; tplayoutObj.Landscape = true; append(rpt,tp); close(rpt); rptview(rpt);
版本历史记录
在 R2016a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)