THotPDF.AddImage Method

 

THotPDF.AddImage

THotPDF

 

Top  Previous  Next

Adds an image to the PDF document and returns an image index that CurrentPage.ShowImage can draw

 

Delphi syntax:

function AddImage(Image: TGraphic; Compression: THPDFImageCompressionType;

                            IsMask: boolean = False; MaskIndex: Integer = -1): Integer; overload;

 

function AddImageAsMask(FileName: TFileName; Compression: THPDFImageCompressionType = icFlate): Integer; overload;

function AddImageWithMask(FileName: TFileName; MaskIndex: Integer; Compression: THPDFImageCompressionType = icJpeg): Integer; overload;

function AddImageWithJpegQuality(FileName: TFileName; Quality: TJPEGQualityRange): Integer; overload;

function AddMonochromeImageAuto(FileName: TFileName): Integer; overload;

 

function AddImage(FileName: TFileName; Compression: THPDFImageCompressionType;

                            IsMask: boolean = False; MaskIndex: Integer = -1): Integer; overload;

 

Description

Call AddImage to register an image and obtain an image handle that can later be drawn with CurrentPage.ShowImage. The file overload accepts BMP, JPEG, and JPEG 2000 files, while the graphic overload accepts a loaded TGraphic instance. Compression selects the PDF image compression method. IsMask indicates whether the image is used as a mask, and MaskIndex identifies the associated mask image

Use AddImageAsMask and AddImageWithMask when you need explicit binary /ImageMask or /Mask wiring without manually passing the low-level IsMask argument. Use AddImageWithJpegQuality to override JpegQuality for one image while preserving the document default for later images. Use AddMonochromeImageAuto or icAutoMono to let HotPDF choose Flate, CCITT Group 4, or JBIG2 for 1-bit bitmap content based on image size and conformance constraints. When two AddImage calls produce identical encoded image data with the same mask relationship, HotPDF reuses the existing image XObject and returns the existing image index instead of embedding a duplicate stream

 

Code Example


var
  ImageHandle: Integer;
begin
  ImageHandle := HPDF.AddImage( '.\Sample.jpg', icJpeg );
  HPDF.CurrentPage.ShowImage( ImageHandle, 100, 200, 150, 100 );  // Draw the image at position 100,200 with size 150x100
end;

 

See also: CurrentPage.ShowImage