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
OptionsTRenderOptions。控制渲染质量和行为的一组 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
OptionsTRenderOptions。控制渲染质量和行为的一组 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
OptionsTRenderOptions。控制渲染质量和行为的一组 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 选中的字体

internal v3.414.2 起,随附的 Windows 原生模块会解析 ExtGState Font 数组引用的字体字典(ISO 32000-1 Table 58 所规定),包括页面 Font 资源表里没有条目的字体

Type3 选择会按显式 Tf 选择一样初始化同一资源上下文与字体度量,继承的字形资源得以保留;这一渲染修正并不附带通用的 Type3 文本重生成或编辑支持

示例

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

参见

RenderTile, PageWidth, PageRotation, ReloadPage