THPDFPage.Width

THPDFPage

 

Top  Previous  Next

Specifies the horizontal size of the page

 

Delphi syntax:

property Width: Single;

 

C++ syntax:

__property float Width;

 

Description

Use the Width property to read or change the width of the page. For standard paper, drawing, card, ID/passport, and photo formats, prefer the predefined THPDFPage.Size enum values such as A2, A3, B2, B4, A5, B5, Tabloid, Ledger, ANSIC, ARCHD, and P8R. Existing psXXX names remain compatible aliases. Use Width and Height with UserDefined only when the required dimensions are not predefined

Width is measured in points and a fresh value is taken as points too. Drawing coordinates run in 1/THotPDF.Resolution inch, so at any Resolution other than 72 read UserWidth for the page width in the units you draw with. Assigning Width makes the page UserDefined, and a UserDefined page draws in points

When the page was loaded from a file, setting Width writes the page's own MediaBox: a MediaBox shared with other pages, or one whose numbers are separate objects, is first replaced by a copy for this page, so other pages and objects keep their values. Setting Width on a page whose canvas has been closed raises EHPDFPageClosedError

Tabloid is 11 x 17 inches. Ledger is the landscape 17 x 11 inch size; do not treat Ledger as another name for portrait Tabloid

Photo-size enum names use a P prefix when the real specification starts with a digit. For example, P5R represents the user-facing 5R photo size

 

Code Example

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.

 

See also: UserWidth, Height, Size