PDFium Delphi Component Docs

RenderPage 方法

元件: TPdf  ·  單元: PDFium
將頁面內容繪製到裝置,像是螢幕、點陣圖或印表機

語法

procedure RenderPage(DeviceContext: HDC; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []);

DeviceContextHDC。要算繪到的目標 Windows 裝置內容(螢幕畫布、印表機 DC 或點陣圖 DC)
Left, TopInteger。裝置內容中目的矩形的左上角,以裝置像素為單位
Width, HeightInteger。目的矩形的大小,以裝置像素為單位。頁面會縮放以填滿此區域
RotationTRotation。套用到頁面的顯示旋轉:ro0(預設)、ro90、ro180 或 ro270
選項TRenderOptions。一組控制算繪品質與行為的 TRenderOption 旗標,例如 reAnnotations、reLcd、reGrayscale 與 rePrinting

 

function RenderPage(Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite): TBitmap;

Left, TopInteger。輸出點陣圖中算繪起始位置的左上偏移,以像素為單位
Width, HeightInteger。目的區域的大小,以像素為單位。頁面會縮放以填滿此區域
RotationTRotation。套用到頁面的顯示旋轉:ro0(預設)、ro90、ro180 或 ro270
選項TRenderOptions。一組控制算繪品質與行為的 TRenderOption 旗標
ColorTColor。算繪前點陣圖的背景填色。預設為 clWhite

 

procedure RenderPage(Bitmap: TBitmap; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite);

BitmapTBitmap。要算繪到的現有 TBitmap。呼叫端負責建立與釋放此點陣圖
Left, TopInteger。點陣圖中算繪起始位置的左上偏移,以像素為單位
Width, HeightInteger。目的區域的大小,以像素為單位。頁面會縮放以填滿此區域
RotationTRotation。套用到頁面的顯示旋轉:ro0(預設)、ro90、ro180 或 ro270
選項TRenderOptions。一組控制算繪品質與行為的 TRenderOption 旗標
ColorTColor。算繪前套用到點陣圖的背景填色。預設為 clWhite

說明

點陣圖多載的 Color = clNone 或 Color = clDefault 選擇透明背景與支援 Alpha 的 PDFium 點陣圖。即使原生頁面背景透明度查詢傳回 false,未覆蓋像素仍保留零 Alpha;clWhite 仍是預設不透明背景

將目前頁面算繪到裝置內容或點陣圖。提供三種多載: (1) 直接算繪到 HDC(適合列印或螢幕繪製); (2) 傳回新建立的 TBitmap,呼叫端必須負責釋放; (3) 算繪到以參數傳入的現有 TBitmap

Left、Top、Width、Height 參數定義輸出矩形。Rotation 套用顯示旋轉(要符合儲存的 頁面旋轉請使用 PageRotation); Flags 控制算繪品質(反鋸齒、LCD 文字等)

透過 ExtGState 選擇的字型

內部 v3.414.2 起,隨附的 Windows 原生模組會解析 ExtGState Font 陣列所參照的字型字典(ISO 32000-1 Table 58 所規範),包括在頁面 Font 資源映射裡沒有條目的字型

Type3 的選擇與明確的 Tf 選擇一樣,會初始化相同的資源情境與字型度量,並保留繼承的 glyph 資源;這項算繪修正並未加入一般性的 Type3 文字重建或編輯支援

範例

var Bmp: TBitmap;
Bmp := Pdf.RenderPage(0, 0, 800, 1000);
try
  Image1.Picture.Assign(Bmp);
finally
  Bmp.Free;
end;

另請參閱

RenderTile, PageWidth, PageRotation, ReloadPage