Subject Re: [IBO] Re: How to store/retrieve PDFs using IBObjects--Thank you! with code that works
Author Chuck Belanger

Thank you! for your help.

I did find the JVCL component and am using the 7zip.dll successfully. (Great! I don't have to load yet another 3rd party component.)

Thank you for the initial code to save the PDF via the INSERT statement. I used that with only minor modifications. Below is the code I used successfully to save and decompress the PDF in the blob.

The whole process is pretty fast, actually faster than the Adobe PDF reader takes to show the PDF and this was using a TCP_IP connection to a remote site.

Regarding the suggestion about storing files on the HD. I really thought about that, but since this is a remote site and will be shared by multiple users, I really did not want to use FTP (my experience with FTP and large file listings or directories is that it is really slow and FTP is more unreliable than storing the file in a DB using a TCP_IP connection). Also, I did not need to make complicated directories to organize the files. The PDF files stored are non-critical, more used by the Admin for oversight of the users.

Overall storing and retrieval is quick. The slowest part is the PDF viewer actually reading and showing them.

Best regards,

Chuck Belanger


On 10/21/2019 10:20 AM, Andeas Hesse ah@... [IBObjects] wrote:
For compressing I use JVCL with 7-zip dll.

Am 21.10.2019 um 17:52 schrieb firebird.users@... [IBObjects]:
 
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;

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 :)



Virus-free. www.avast.com