THPDFPage.Width

THPDFPage

 

顶部  上一页  下一页

指定页面的水平尺寸

 

Delphi 语法:

property Width: Single;

 

C++ 语法:

__property float Width;

 

说明

使用 Width 属性读取或更改页面宽度。对于标准 paper、drawing、card、ID/passport 和 photo formats,请优先使用预定义 THPDFPage.Size enum 值,例如 A2、A3、B2、B4、A5、B5、Tabloid、Ledger、ANSIC、ARCHD 和 P8R。现有 psXXX 名称仍是兼容别名。只有所需尺寸未预定义时,才将 Width 和 Height 与 UserDefined 一起使用

Width 以 point 为单位,新值也按 point 解释。绘图坐标以 1/THotPDF.Resolution inch 为单位,因此 Resolution 不是 72 时,请读 UserWidth 来获得与绘图单位一致的页面宽度。设置 Width 会把页面变为 UserDefined,而 UserDefined 页面以 point 绘制

页面从文件载入时,设置 Width 会写入页面自己的 MediaBox:与其他页面共享的 MediaBox,或数值存放在独立对象中的 MediaBox,会先替换为本页面专属的副本,因此其他页面对象保持原值。对画布已关闭的页面设置 Width 会抛出 EHPDFPageClosedError

Tabloid 为 11 x 17 英寸。Ledger 是横向的 17 x 11 英寸尺寸;不要把 Ledger 当作纵向 Tabloid 的另一个名称

当真实规格以数字开头时,照片尺寸枚举名称使用 P 前缀。例如,P5R 表示面向用户的 5R 照片尺寸

 

代码示例

program CustomPageSize;
{$APPTYPE CONSOLE}
uses
  SysUtils,
  HPDFDoc;

var
   HPDF: THotPDF;

begin
    HPDF:= THotPDF.Create(  nil  );
    try
        HPDF.AutoLaunch := true;                // PDF file will be shown automatically
        HPDF.FileName := 'CustomPageSize.pdf';  // Set PDF filename
        HPDF.PageLayout := plOneColumn;  // Set one column viewer mode

        HPDF.BeginDoc;                              // Create PDF file

        HPDF.CurrentPage.Size := UserDefined;
        HPDF.CurrentPage.Width := 1024 / 25.4 * 72;   // 1024 mm in PDF points
        HPDF.CurrentPage.Height := 768 / 25.4 * 72;   // 768 mm in PDF points
        HPDF.CurrentPage.TextOut(10, 10, 0, '1024 x 768 mm custom page');

        HPDF.EndDoc;                                                       // Close PDF file
    finally
        HPDF.Free;
    end;
end.

 

另请参阅: UserWidth, Height, Size