Docs de PDFiumVCL

ImageCount property

Esta entrada API conserva identificadores, firmas, bloques de código y términos PDF en su forma original.
Component: TPdf  ·  Unit: PDFium
Number of raster image XObjects on the currently active page.

Syntax

property ImageCount: Integer; // read only

Description

ImageCount enumerates every page object whose type is FPDF_PAGEOBJ_IMAGE on the page selected by PageNumber. In PDF terms these are the Image XObjects referenced from the page’s content stream (PDF 1.7 spec section 8.9). Vector content, form XObjects, shadings and text glyphs are intentionally excluded, so the value matches what a human reader would call a “picture” on the page.

The property requires Active to be True and a valid PageNumber. When the document is not loaded the value is 0. ImageCount is a per-page quantity; iterate every page and accumulate the count to get a document-wide total. ImageCount is equivalent to BitmapCount and is provided to pair naturally with the Image[Index] indexer, which returns a decoded TPdfImage record (Width, Height, raw pixel bytes).

The typical loop pattern is for I := 0 to Pdf.ImageCount - 1 do, with Pdf.Image[I] giving the decoded pixels. Cost scales with image data size because PDFium decodes JPEG / JPEG2000 / CCITTFax / Flate streams on demand; cache the result if you need it more than once per page.

Remarks

Example

// Save every image on the current page to disk.
var I: Integer;
var Img: TPdfImage;
begin
  Pdf1.Active := True;
  for I := 0 to Pdf1.ImageCount - 1 do
  begin
    Img := Pdf1.Image[I];
    TFile.WriteAllBytes(Format('page%d_img%d.bin', [Pdf1.PageNumber, I]), Img.Data);
  end;
end;

See Also

Image, BitmapCount, Bitmap, ObjectCount