THPDFPage Class

 

THPDFPage

方法         屬性      總覽

傳回頂部  上一頁  下一頁

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

當文字座標要對齊字型基線、而不是預設的頂端位置時,請用 TextFromBaseLine(True);需要完全由呼叫端提供的字型程式與 glyph ID 時,請用 SetEmbeddedGlyphFont 與 DrawEmbeddedGlyphRun;要讓進階 PDF 運算子自動包在一組圖形狀態儲存與還原之中時,請用 AppendScopedRawContent;需要回報已寫入字元數、列數與溢位狀態的換行文字輸出時,請用 TextOutBoxEx / WideTextOutBoxEx

一般流程中,執行個體由 THotPDF 建立並擁有:頁面在 BeginDoc 之後經由 AddPage、InsertPage 與 CurrentPage 屬性取得,以 EndDoc 收尾文件或銷毀元件時會釋放每一頁;公開的無參數 Create 建構子與 Destroy 解構子則可供文件工作階段之外的獨立頁面物件使用,單元測試正是這樣在不建完整元件的情況下驗證頁面層級預設值

 

單元

HPDFDoc.pas

 

說明

使用 THPDFPage 繪製 paths、放置文字、render images,並控制 size、orientation 與 graphics state 等 page-level settings

 

使用範例:

 

uses

  ...

  HPDFDoc,

  ...

 

type

   ...

   HPDF: THotPDF;

   ...

 

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.EndDoc;                                                         // Finalize and save the PDF

end;