TAdvPDFLib pointer error

Using C++ Builder 12.3 and VCL UI Pack 13.5.2

I'm having this error produced during compile:
[bcc32c Error] frmEmployee.cpp(327): member reference type 'Advpdfgraphicslib::_di_IAdvCustomPDFGraphicsLib (__closure *)() attribute((fastcall))' is not a pointer

code:

auto pdf = std::make_unique(this);
pdf->BeginDocument("test.pdf");
pdf->NewPage();

auto img = std::make_unique(sql->AsString("image"));
auto png = std::make_unique();
png->LoadFromStream(img.get());

pdf->Graphics->DrawImage(png, PointF(10, 50)); // <--- ERROR PRODUCED HERE

// I also get the same error when performing
// pdf->Graphics->DrawImageFromFile("MyImage.png", PointF(10, 50));

Any suggestions? And thanks for any help!

Hi Stephen,

The error you are seeing:

[bcc32c Error] frmEmployee.cpp(327): member reference type 'Advpdfgraphicslib::_di_IAdvCustomPDFGraphicsLib (__closure *)() __attribute__((fastcall))' is not a pointer

is due to the way the Graphics property of TAdvPDFLib is accessed in C++ Builder.

In Delphi, the Graphics property is an interface reference, but in C++ Builder, it is exposed as a getter method returning an interface. So when you do:

pdf->Graphics->DrawImage(...);

the compiler complains because Graphics is a method, not a pointer or object you can directly dereference.

To fix this, you need to call the getter method explicitly, like this:

pdf->Graphics()->DrawImage(png, PointF(10, 50));

Notice the parentheses after Graphics indicating a method call.

Similarly, for DrawImageFromFile:

pdf->Graphics()->DrawImageFromFile("MyImage.png", PointF(10, 50));

This should resolve the pointer error.

Let me know if you need further assistance!

Worked like a champ - thank you!

1 Like