AddBitmapHandle
Declaration
Delphi
function TSignApi4Object.AddBitmapHandle(hBitmap: HBITMAP; Left, Top, Width, Height: Double; PageNumber: Integer):Integer; stdcall;
ActiveX
HRESULT _stdcall AddBitmapHandle([in] OLE_HANDLE hBitmap, [in] double Left, [in] double Top, [in] double Width, [in] double Height, [in] long PageNumber, [out, retval] long * RetVal );
Description
Use this function to insert a Bitmap into the PDF document from an HBITMAP. The Left,Top,Width,Height are the PDF coordinates of the insertion.
Important: Be sure to call LoadDoc before calling this function! |
Arguments
| The HBITMAP to an image |
| Position from the left side in PDF coordinates |
Top | Position from the top side in PDF coordinates |
Width | Size Width of Viewing area from the Image |
Height | Size Height of the Viewing Area from Image |
PageNumber | Pagenumber in the PDF document from 1..n |
Return value
value | name | description |
---|---|---|
0 | abError_BLSLIBÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â | Insertion error from Library |
1 | abOk | Insertion sucessfull |
2 | abError_LoadException | Exception while Loading File, wrong file format |
3 | abError_BitmapError | Bitmap from File is undefined or size of bitmap is 0/0 |
4 | abError_HBITMAPInvalid | The delivered HBITMAP is 0 or INVALID_HANDLE_VALUE |
5 | abError_BLSException | Exception while inserting bitmap |
6 | abError_NoDocLoaded | No document loaded, use LoadDoc |
7 | abError_DocIsSigned | The document is already signed. |
8 | abError_BMPSizeTooBig | The Bitmap is too big for the pdf document |
Samples
Delphi - AddBitmapHandle
procedure TForm1.ButtonAddBMPHandleClick(Sender: TObject); var RetCode : Integer; bmp : TBitmap; msg : String; begin OpenDialog1.Filter := 'Bitmap|*.bmp|All|*.*'; if (not OpenDialog1.Execute()) then exit; bmp := TBitmap.Create; bmp.LoadFromFile(OpenDialog1.FileName); RetCode := SignApi.AddBitmapHandle(bmp.Handle, strtofloat(EditAddBMPLeft.Text), strtofloat(EditAddBMPTop.Text), strtofloat(EditAddBMPWidth.Text), strtofloat(EditAddBMPHeight.Text), strtoint(EditAddBMPPageNumber.Text) ); bmp.Free; case RetCode of 0 : // abError_BLSLIB msg := 'Error from Library'; 1 : // abOk msg := 'Image inserted successfully'; 2 : // abError_LoadException msg := 'Exception when loading image'; 3 : // abError_BitmapError msg := 'Bitmap is NIL or Size=0/0'; 4 : // abError_HBITMAPInvalid msg := 'Bitmap handle is invalid'; 5 : // abError_BLSException msg := 'Exception in library'; 6 : // abError_NoDocLoaded msg := 'No document loaded'; 7 : // abError_DocIsSigned msg := 'Document is already signed - no image insertion possible'; 8 : // abError_BMPSizeTooBig msg := 'Image size too big'; else msg := 'unknown error = ' + inttostr(RetCode); end; MessageBox(Handle, PChar(msg), 'AddBitmapFile', MB_OK or MB_ICONINFORMATION); end;