MATLAB 帮助中心
本页采用了机器翻译。点击此处可查看最新英文版本。
命名空间: mlreportgen.dom
Microsoft Word 和 PDF 报告中的页面大小和方向
使用 mlreportgen.dom.PageSize 类的对象来指定 Microsoft® Word 或 PDF 报告中页面的高度、宽度和方向。
mlreportgen.dom.PageSize
mlreportgen.dom.PageSize 类是一个 handle 类。
handle
ConstructOnLoad
true
HandleCompatible
有关类属性的信息,请参阅类属性。
PageSizeObj = mlreportgen.dom.PageSize 创建一个 PageSize 对象,该对象具有属性,指定高度为 11 英寸、宽度为 8.5 英寸且为纵向。
PageSizeObj = mlreportgen.dom.PageSize
PageSizeObj
PageSize
PageSizeObj = mlreportgen.dom.PageSize(height,width) 创建具有指定高度和宽度以及纵向方向的页面大小对象。
PageSizeObj = mlreportgen.dom.PageSize(height,width)
height
width
PageSizeObj = mlreportgen.dom.PageSize(height,width,orientation) 创建具有指定高度、宽度和方向的页面大小对象。
PageSizeObj = mlreportgen.dom.PageSize(height,width,orientation)
orientation
示例
全部展开
Height
"11in"
页面的高度,指定为字符向量或字符串标量,其中包含一个数字,后跟一个测量单位的缩写。例如,"11in" 指定 11 英寸。有效的缩写是:
"px" - 像素
"px"
"cm" - 厘米
"cm"
"in" - 英寸
"in"
"mm" - 毫米
"mm"
"pc" - 派卡
"pc"
"pt" - 磅
"pt"
GetAccess
public
SetAccess
NonCopyable
Width
"8.5in"
页宽,指定为字符向量或字符串标量,包含一个数字后跟一个测量单位的缩写。例如,"8.5in" 指定 8.5 英寸。有效的缩写是:
数据类型: char | string
char
string
Orientation
"portrait"
"landscape"
页面方向,指定为以下字符向量或字符串标量之一:
"portrait" 表示垂直方向
"landscape" 表示水平方向
Height 和 Width 属性确定页面方向,而不管 Orientation 属性的值如何。不过,最佳做法是将 Orientation 属性设置为与页面尺寸一致的值。如果高度大于宽度,则将 Orientation 设置为 "portrait"。如果宽度大于高度,则将 Orientation 设置为 "landscape"。
Tag
标记,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标记。生成的标记形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。使用此值来帮助确定在文档生成过程中出现的问题的位置。
CLASS:ID
CLASS
ID
Id
目标标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。
全部折叠
使用 PageSize 对象指定文档的页面大小。在 PageSize 对象中,将 Orientation 属性设置为与 Height 和 Width 属性一致的值。
默认情况下,文档的页面高度为 11 英寸,宽度为 8.5 英寸,并且为纵向。您可以通过设置文档布局对象使用的 Height 对象的 Width 和 PageSize 属性来覆盖默认页面大小。例如指定 Height 为 "10in",Width 为 "8in",Orientation 为 "portrait"。
"10in"
"8in"
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。
rotate
portrait
landscape
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);
使用 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 属性。此示例指定报告的所有页面均为横向。
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 中推出
mlreportgen.dom.DOCXPageLayout | mlreportgen.dom.PDFPageLayout | mlreportgen.dom.PageMargins | mlreportgen.report.ReportLayout | mlreportgen.report.ReporterLayout
mlreportgen.dom.DOCXPageLayout
mlreportgen.dom.PDFPageLayout
mlreportgen.dom.PageMargins
mlreportgen.report.ReportLayout
mlreportgen.report.ReporterLayout
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处