Docs PDFiumVCL

AddPicture method

Questa voce API conserva identificatori, firme, blocchi di codice e termini PDF nella forma originale.
Component: TPdf  ·  Unit: PDFium
Add picture to the current PDF page using the specified coordinates.

Syntax

procedure AddPicture(Picture: TPicture; X, Y: Double);

PictureTPicture. The source picture object to embed. The graphic inside Picture is converted and placed on the page at natural size (derived from Picture.Width / Picture.Height in pixels, mapped to PDF user units).

 

procedure AddPicture(Picture: TPicture; X, Y, Width, Height: Double);

PictureTPicture. The source picture object to embed. The graphic is scaled to fit the specified Width × Height rectangle on the page.

Description

AddPicture embeds the graphic held in a TPicture object onto the current PDF page. Two overloads are provided: the three-coordinate form places the picture at its natural size, while the five-coordinate form scales it to an explicit Width × Height rectangle.

TPicture is the standard VCL/LCL container for any registered graphic format. Because it is not format-specific, you can pass bitmaps, PNG images, JPEG images, or any other graphic that has been loaded into a TPicture instance. For placing a plain TBitmap directly, consider AddImage instead. For raw JPEG stream data, use AddJpegImage.

The X and Y parameters define the lower-left corner of the image in PDF user units (origin at page lower-left, Y increases upward). When Width and Height are omitted, the placement size is derived from the picture's pixel dimensions assuming 72 DPI.

Example

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;

See Also

AddImage, AddJpegImage, AddText