Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : Bad behaviour of what?
| Subject: | Bad behaviour of what? |
| Posted by: | "Massimo Bolzoni" (massimo.bolzo..@mandelli.com) |
| Date: | Mon, 10 Jul 2006 17:49:30 |
Hi friends, help me please!
Delphi 2005 Ent Upd 3. Windows XP SP2, browser IE6.
I'm working locally.
I must show a PDF file in a IE window.
But the result is: a new blank browser window and the PDF file
is shown in a real Acrobat Reader window.
-------------------------------------------------
Here's my code.
In a HTML page, at Javascript level, I make:
window.open("/scripts/CGI_PDFReport.exe");
The Apache 2 server activates the CGI_PDFReport.exe script.
In this CGI I have:
procedure TWebModule_PDFReport.WebModule_PDFReportWebActionItem_DefAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
lst: string;
lLen: integer;
lStrVCL: TIdStreamVCL;
lStrM: TMemoryStream;
begin
IdTCPClient.Connect;
lStrM := TMemoryStream.Create;
lStrVCL := TIdStreamVCL.Create(lStrM);
try
IdTCPClient.IOHandler.WriteLn('GetReport');
lLen := StrToInt(IdTCPClient.IOHandler.ReadLn);
IdTCPClient.IOHandler.ReadStream(lStrVCL,lLen);
lStrM.Position := 0;
Response.ContentStream := lStrM;
finally
IdTCPClient.Disconnect;
end;
end;
This CGI communicates an Application Server that serves the PDF file.
procedure TformMainASPDF.IdTCPServerExecute(AContext: TIdContext);
begin
if (AContext.Connection.IOHandler.ReadLn = 'GetReport') then begin
AContext.Connection.IOHandler.WriteLn('21598'); //PDF file dimension
AContext.Connection.IOHandler.WriteFile('Prova.pdf',false);
end;
end;
Any help will be much appreciated!
Bye, Massimo.