Subject | AW: [IBO] Re: Storing PDF into Firebird Blobs |
---|---|
Author | Terry Black |
Post date | 2012-05-23T00:41:26Z |
Hi Herbert, If I set the filename to 'abc' in the FormActivate to start then it is just conditional branching. This is not very elegant code but it works Ok. It just keeps switching the filename.
procedure TForm1.IB_Grid1Click(Sender: TObject);
begin
if filename = 'abc' then
begin
filename := 'def';
DM.qrBlob.FieldByName('PDF').SaveToFile('D:\myfolder\' + filename + '.pdf');
end
else
if filename = 'def' then
begin
filename := 'abc';
DM.qrBlob.FieldByName('PDF').SaveToFile('D:\myfolder\' + filename + '.pdf');
end;
VSPDFViewer1.Clear; //clear the viewer
VSPDFViewer1.Load('D:\myfolder\' + filename + '.pdf','') //view the PDF
end;
Terry
IT Manager | Public Health Unit Hornsby | Health Reform Transitional Organisation Northern
Hornsby Hospital, Main Building 1, 36-76 Palmerston Road, Hornsby NSW 2077
Tel. 02 9477 9400 | Fax. 02 9482 1650 | tblac@...
www.health.nsw.gov.au
I would store all these files in the same path, but with different file
names
(e.g. constructed by the key field(s) of your qryScan row, which would
uniquely identify the file and link it to the row).
You might have to check before writing the blob to a file if this concrete
file already
exists and then decide to delete it first and to create it newly (to
"reload") or not
to reread the blob's content and to view this existing file.
Herbert
Von: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] Im Auftrag
von Terry Black
Gesendet: Dienstag, 22. Mai 2012 06:48
An: IBObjects@yahoogroups.com
Betreff: AW: AW: [IBO] Re: Storing PDF into Firebird Blobs
Thanks, Herbert and Jason - the code works well. I can load PDF images into
blob fields. My intention is to just click on a record in a table and have
it display the contents of the blob which is a PDF. But I have a problem
with the Blob being saved to a file.
When I click on the first record
DM.qryScan.FieldByName('PDFIMAGE').SaveToFile(myPath + '\myPdf.pdf') the
first time it creates a file called myPDF.pdf when I click on the second
record I get an EFCreateError ' Cannot create file D:\apdf\mypdf.pdf' the
process cannot access the file because it is being used by another process.
In other words I need to write it to some temporary location.
Terry
[Non-text portions of this message have been removed]
Disclaimer: This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the individual sender, and are not necessarily the views of the Local Health District or associated entities.
procedure TForm1.IB_Grid1Click(Sender: TObject);
begin
if filename = 'abc' then
begin
filename := 'def';
DM.qrBlob.FieldByName('PDF').SaveToFile('D:\myfolder\' + filename + '.pdf');
end
else
if filename = 'def' then
begin
filename := 'abc';
DM.qrBlob.FieldByName('PDF').SaveToFile('D:\myfolder\' + filename + '.pdf');
end;
VSPDFViewer1.Clear; //clear the viewer
VSPDFViewer1.Load('D:\myfolder\' + filename + '.pdf','') //view the PDF
end;
Terry
IT Manager | Public Health Unit Hornsby | Health Reform Transitional Organisation Northern
Hornsby Hospital, Main Building 1, 36-76 Palmerston Road, Hornsby NSW 2077
Tel. 02 9477 9400 | Fax. 02 9482 1650 | tblac@...
www.health.nsw.gov.au
>>> "Herbert Senner" <hsenner@...> 23/05/2012 1:55 am >>>Terry,
I would store all these files in the same path, but with different file
names
(e.g. constructed by the key field(s) of your qryScan row, which would
uniquely identify the file and link it to the row).
You might have to check before writing the blob to a file if this concrete
file already
exists and then decide to delete it first and to create it newly (to
"reload") or not
to reread the blob's content and to view this existing file.
Herbert
Von: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] Im Auftrag
von Terry Black
Gesendet: Dienstag, 22. Mai 2012 06:48
An: IBObjects@yahoogroups.com
Betreff: AW: AW: [IBO] Re: Storing PDF into Firebird Blobs
Thanks, Herbert and Jason - the code works well. I can load PDF images into
blob fields. My intention is to just click on a record in a table and have
it display the contents of the blob which is a PDF. But I have a problem
with the Blob being saved to a file.
When I click on the first record
DM.qryScan.FieldByName('PDFIMAGE').SaveToFile(myPath + '\myPdf.pdf') the
first time it creates a file called myPDF.pdf when I click on the second
record I get an EFCreateError ' Cannot create file D:\apdf\mypdf.pdf' the
process cannot access the file because it is being used by another process.
In other words I need to write it to some temporary location.
Terry
[Non-text portions of this message have been removed]
Disclaimer: This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the individual sender, and are not necessarily the views of the Local Health District or associated entities.