Subject | Re: How to store/retrieve PDFs using IBObjects |
---|---|
Author | |
Post date | 2019-10-21T15:52:20Z |
I'm not familiar with the Abbrevia components but assuming they give you a TStream for your compressed PDF, to save it to the database you can try passing it into a function something like this:
procedure LoadFromStream(const S: TIB_Statement; const ParamName: string; const InputStream: TStream);
var
wStream: TStream;
blob: TIB_ColumnBlob;
begin
blob := S.ParamByName(ParamName) as TIB_ColumnBlob;
wStream := S.CreateBlobStream(blob, bsmWrite);
try
wStream.CopyFrom(InputStream, 0);
finally
wStream.Free;
end;
end;
var
wStream: TStream;
blob: TIB_ColumnBlob;
begin
blob := S.ParamByName(ParamName) as TIB_ColumnBlob;
wStream := S.CreateBlobStream(blob, bsmWrite);
try
wStream.CopyFrom(InputStream, 0);
finally
wStream.Free;
end;
end;
Example call:
ib_dsql.SQL.Text := 'insert into PDF_TABLE (ID, PDF_FILE) values (1, :PDF_FILE)';
LoadFromStream(ib_dsql, 'PDF_FILE', StreamFromAbbrevia);
ib_dsql.Execute;
I'm sure you can streamline this, just an example, hope it helps :)