FitImageAndRelease
Image handling, Page layout, Optimisation
Description
Fits the specified image inside a target rectangle, preserves the image aspect ratio, applies the requested alignment and rotation, then releases that image handle from the document image cache
Use this helper when a batch generator adds many one-use images that should not remain selectable after placement
Syntax
Delphi
Function TPDFlib.FitImageAndRelease(ImageID: Integer; Left, Top, Width, Height: Double; HAlign, VAlign, Rotate: Integer): Integer;
ActiveX
Function PDFlib::FitImageAndRelease(ImageID As Long, Left As Double, Top As Double, Width As Double, Height As Double, HAlign As Long, VAlign As Long, Rotate As Long) As Long
DLL
int DLFitImageAndRelease(int InstanceID, int ImageID, double Left, double Top, double Width, double Height, int HAlign, int VAlign, int Rotate);
Parameters
| ImageID | The image handle returned by an image creation or import function |
|---|---|
| Left | The horizontal co-ordinate of the target rectangle |
| Top | The vertical co-ordinate of the target rectangle |
| Width | The target rectangle width |
| Height | The target rectangle height |
| HAlign | Horizontal alignment inside the rectangle, where 0 is left, 1 is centre, and 2 is right |
| VAlign | Vertical alignment inside the rectangle, where 0 is top, 1 is centre, and 2 is bottom |
| Rotate | Rotation mode, where 0 is normal, 1 is 90 degrees anti-clockwise, 2 is 90 degrees clockwise, and 3 is 180 degrees |
Return values
| 0 | The image handle was invalid, a placement option was out of range, the image could not be drawn, or the handle could not be released |
|---|---|
| 1 | The image was fitted and the handle was released |
Remarks
The saved PDF keeps the image object because the page resource dictionary already references it before the cache handle is released
After this function succeeds, SelectImage(ImageID) returns 0 for that released handle