THPDFPage Class

 

THPDFPage

Methods         Properties      Overview

Top  Previous  Next

THPDFPage represents a single page in the PDF document.

 

Unit

HPDFDoc.pas

 

Description

Use THPDFPage to draw paths, place text, render images, and control page-level settings such as size, orientation, and graphics state

Use TextFromBaseLine(True) when text coordinates should refer to the font baseline instead of the default top-edge position, use SetEmbeddedGlyphFont and DrawEmbeddedGlyphRun for exact caller-owned font programs and glyph IDs, use AppendScopedRawContent when expert PDF operators should be wrapped in an automatic graphics-state save and restore pair, and use TextOutBoxEx / WideTextOutBoxEx when wrapped text output should report written characters, written rows, and overflow status

In normal workflows instances are created and owned by THotPDF: pages arrive through AddPage, InsertPage, and the CurrentPage property after BeginDoc, and closing the document with EndDoc or destroying the component releases every page; the public parameterless Create constructor and Destroy destructor are available for standalone page objects outside a document session, which is how unit tests exercise page-level defaults without a full component

 

Using example:

 

uses

  ...

  HPDFDoc,

  ...

 

type

   ...

   HPDF: THotPDF;

   TextBoxResult: THPDFTextOutBoxResult;

   ...

 

procedure TForm1.HelloWorldButtonClick(Sender: TObject);

begin

   HPDF.AutoLaunch := true;                                          // Show the PDF after it is created

   HPDF.FileName := '.\HelloWorld.pdf';

   HPDF.BeginDoc;                                                       // Start PDF generation

   HPDF.CurrentPage.TextOut(10, 10, 0, 'Hello World!');  // Write text on the first page

   HPDF.CurrentPage.TextFromBaseLine(true);  // Treat following text Y values as baselines

   HPDF.CurrentPage.TextOut(10, 40, 0, 'Baseline text');

   HPDF.CurrentPage.TextFromBaseLine(false);

   TextBoxResult := HPDF.CurrentPage.TextOutBoxEx(10, 70, 2, 180, 48, 'Wrapped text-box content', jtLeft);

   HPDF.CurrentPage.AppendScopedRawContent('2 w 10 10 120 45 re S');

   HPDF.EndDoc;                                                         // Finalize and save the PDF

end;