procedure AddPicture(Picture: TPicture; X, Y: Double);
| Picture | TPicture。要內嵌的來源圖片物件。Picture 內的圖形會被轉換,並以自然尺寸(由 Picture.Width / Picture.Height 的像素值推導,映射至 PDF 使用者單位)放置到頁面上 |
procedure AddPicture(Picture: TPicture; X, Y, Width, Height: Double);
| Picture | TPicture。要內嵌的來源圖片物件。圖形會縮放至符合頁面上指定的 Width × Height 矩形 |
AddPicture 會將 TPicture 物件中持有的圖形內嵌到目前的 PDF 頁面。提供兩個多載:三座標形式以自然尺寸放置圖片,五座標形式則將圖片縮放至明確的 Width × Height 矩形
TPicture 是適用於任何已註冊圖形格式的標準 VCL/LCL 容器。由於它不限於特定格式,您可以傳入點陣圖、PNG 影像、JPEG 影像,或任何已載入 TPicture 執行個體的其他圖形。若要直接放置單純的 TBitmap,可考慮改用 AddImage。若是原始 JPEG 串流資料,請使用 AddJpegImage
X 與 Y 參數以 PDF 使用者單位定義影像的左下角(原點在頁面左下,Y 軸向上遞增)。省略 Width 與 Height 時,放置尺寸會以 72 DPI 的假設從圖片的像素尺寸推導
var
Pic: TPicture;
begin
Pic := TPicture.Create;
try
Pic.LoadFromFile('C:\Images\chart.png');
// Place at natural size, lower-left at (72, 500)
Pdf1.AddPicture(Pic, 72, 500);
// Or scale to an explicit 300 x 200 pt rectangle
Pdf1.AddPicture(Pic, 72, 200, 300, 200);
finally
Pic.Free;
end;
end;