Subject AW: AW: [IBO] Re: Storing PDF into Firebird Blobs
Author Herbert Senner
Terry,



In your code you did not assign a value to the string xxx!?

Is It just for abbreviation or is the variable xxx actually not initialized?



Its value should be a valid new filename (I store such files as temporary
files
and delete them when they are no longer needed).



The mechanism is: The blob contents are transferred to a file in the
file system and then can be viewed by an application (e.g. a pdf viewer).
If the function is successful, you should find the file in its path
location.
If in your case the newly created file has the extension 'pdf' and this
extension is linked to a special application you can open it from within
your application with the Win32 API ShellExecuteEx-function.



Here is a code snippet:



Var

Xxx (I would prefer fileName): string;



begin

Xxx := myPath + '\myFile.pdf';

If ReadFromBlobToFile(ibColumn, xxx) then

// e.g. ShellExecuteEx to open the file within its linked application

end;

If you want to store the blob content in a string variable (is it that
what you intended to do? You would not be very happy with the pdf contents
in a string I suppose) then you would use the
ReadFromBlobToStream-function.



Var

sStream: TStringStream;

xxx: string;
begin

sStream := TStringStream.Create;

try

if ReadFromBlobToStream(IBColumn, sStream) then

xxx := sStream.DataString;

// do whatever with xxx

finally

sStream.Free;

end;

end;





Herbert



Von: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] Im Auftrag
von Terry Black
Gesendet: Montag, 21. Mai 2012 13:35
An: IBObjects@yahoogroups.com
Betreff: Re: AW: [IBO] Re: Storing PDF into Firebird Blobs





Hi Herbert, If I use WriteFromFileToBlob('C:\db\dell.pdf',
DM.qrScan.FieldByName('PDFIMAGE'));

this puts the PDF file into the blob, but I am having trouble getting it out
and displaying it.

If I try the reverse

procedure TfrMain.Button5Click(Sender: TObject);
var xxx:string;
begin
ReadFromBlobToFile(DM.qrScan.FieldByName('PDFIMAGE'),xxx);
end;

it does not work.

Terry

Terry Black
IT Manager
Northern Sydney Central Coast
Public Health Unit (Hornsby Office)






[Non-text portions of this message have been removed]