DrawImage using TAdvPDFLib

Referencing documentation:

Pages 18-19 state I should be able to create a TBitmap and then print it using the DrawImage function.

Using those examples, I created the code (where img is a TStringStream of an image BLOB):

  auto bmp = std::make_unique<TBitmap>();
  bmp->LoadFromStream(img.get());

  pdf->Graphics()->DrawImage(bmp.get(), RectF(nLeft, nTop, nLeft + RPT_CELL_WIDTH, nTop + RPT_CELL_HEIGHT));

I'm getting an error stating no matching member function for call to DrawImage. This works if I pass a fully qualified path to an image file.

Any ideas?

You cannot pass a TBitmap directly to DrawImage in TAdvPDFLib. Instead, convert your TBitmap to a TAdvPicture first, then pass that to DrawImage:

auto bmp = std::make_unique<TBitmap>();
bmp->LoadFromStream(img.get());

auto advPic = std::make_unique<TAdvPicture>();
advPic->LoadFromBitmap(bmp.get());

pdf->Graphics()->DrawImage(advPic.get(), RectF(nLeft, nTop, nLeft + RPT_CELL_WIDTH, nTop + RPT_CELL_HEIGHT));

Make sure you include the AdvPicture unit for TAdvPicture. This will fix the "no matching member function" error.