Reports in intraweb problem
I have the following code gleaned from other source.
var
LFile: string;
LURL: string;
LOptions: string;
LWindowName: string;
begin
UserSession.ppReport1.Reset;
UserSession.ppReport1.Template.FileName :=
'c:\test\Server_tables\reports\Licence Agreement2.rtm';
UserSession.ppReport1.Template.LoadFromFile;
UserSession.ppReport1.AllowPrintToFile := True;
UserSession.ppReport1.ShowPrintDialog := False;
UserSession.ppReport1.TextFileName := 'c:\test\files\Licence.PDF';
UserSession.ppReport1.DeviceType := 'PDFFile';
UserSession.ppReport1.Print;
LWindowName := 'Report';
LOptions := 'scrollbars=yes,width=400,height=600';
LURL := LFile;
LURL := WebApplication.AppURLBase + WebApplication.AppID + '/' + LFile;
AddToInitProc('NewWindow("' +WebApplication.AppURLBase +
'c:\test\files\Licence.PDF'+ '", "","");');
end;
This produce the file in C:\test\file\licence.pdf as expected.
What I don't understand is the syntax to show this file in a new window.
_____________________________________________________________________________________
Also in servercontrol onsessioncreate I have the following Code.
const
tempDir = 'C:\test\net\TEMP';
var
threadID : string;
newPrivateDir : string;
begin
ASession.Data := TIWUserSession.Create(nil);
threadID := WebApplication.AppID;
if not DirectoryExists(tempdir) then
begin
if not CreateDir(tempdir) then
raise Exception.Create('Cannot create ' + tempDir);
end;
threadID := WebApplication.AppID;
newPrivateDir := tempDir + '\' + threadID;
if not DirectoryExists(newPrivateDir) then
CreateDir(newPrivateDir);
Usersession.Session1.PrivateDir := newPrivateDir;
end;
This creates a new directory on a new session and places the lock files for
each session in the directory.
How do I reference this created directory so I can place the licence.pdf
into this directory?
_______________________________________________________________________________
I have placed the reportwriter components into the UserSessionUnit, since
adding these the app fails to start properly. I have to restart it several
times before it runs.
Is this the correct place for these components.
Cheers SteveW
var
LFile: string;
LURL: string;
LOptions: string;
LWindowName: string;
begin
UserSession.ppReport1.Reset;
UserSession.ppReport1.Template.FileName :=
'c:\test\Server_tables\reports\Licence Agreement2.rtm';
UserSession.ppReport1.Template.LoadFromFile;
UserSession.ppReport1.AllowPrintToFile := True;
UserSession.ppReport1.ShowPrintDialog := False;
UserSession.ppReport1.TextFileName := 'c:\test\files\Licence.PDF';
UserSession.ppReport1.DeviceType := 'PDFFile';
UserSession.ppReport1.Print;
LWindowName := 'Report';
LOptions := 'scrollbars=yes,width=400,height=600';
LURL := LFile;
LURL := WebApplication.AppURLBase + WebApplication.AppID + '/' + LFile;
AddToInitProc('NewWindow("' +WebApplication.AppURLBase +
'c:\test\files\Licence.PDF'+ '", "","");');
end;
This produce the file in C:\test\file\licence.pdf as expected.
What I don't understand is the syntax to show this file in a new window.
_____________________________________________________________________________________
Also in servercontrol onsessioncreate I have the following Code.
const
tempDir = 'C:\test\net\TEMP';
var
threadID : string;
newPrivateDir : string;
begin
ASession.Data := TIWUserSession.Create(nil);
threadID := WebApplication.AppID;
if not DirectoryExists(tempdir) then
begin
if not CreateDir(tempdir) then
raise Exception.Create('Cannot create ' + tempDir);
end;
threadID := WebApplication.AppID;
newPrivateDir := tempDir + '\' + threadID;
if not DirectoryExists(newPrivateDir) then
CreateDir(newPrivateDir);
Usersession.Session1.PrivateDir := newPrivateDir;
end;
This creates a new directory on a new session and places the lock files for
each session in the directory.
How do I reference this created directory so I can place the licence.pdf
into this directory?
_______________________________________________________________________________
I have placed the reportwriter components into the UserSessionUnit, since
adding these the app fails to start properly. I have to restart it several
times before it runs.
Is this the correct place for these components.
Cheers SteveW
This discussion has been closed.
Comments
I moved all the reportwriter componentsonto the main form and still has the
same 'Buggy' problems.
If I remove all the reportwriter components my app runs fine.
Any help pointers appreciated.
AddToInitProc('NewWindow("c:\test\files\Licence.PDF","","");');
This should work if you're browsing on the same machine as the IW
server but you'll need to sort out the proper URL to view the file from
an external browser.
eg.
var FilesDIR, FilesURL : string;
FilesDIR := gServerController.FilesDIR;
UserSession.ppReport1.TextFileName := FilesDIR + 'Licence.PDF';
UserSession.ppReport1.DeviceType := 'PDFFile';
UserSession.ppReport1.Print;
LWindowName := 'Report';
LOptions := 'scrollbars=yes,width=400,height=600';
FilesURL := gServerController.FilesURL + 'Licence.PDF'
AddToInitProc('NewWindow("'+FilesURL+'","","");');
or
AddToInitProc('NewWindow("'+FilesURL+'","'+LWindowName+'","'+LOptions+'
");');
Create the temp directories below the Files directory:
OnSessionCreate...
tempdir := gServerController.FilesDIR + '\temp';
threadID := WebApplication.AppID;
newPrivateDir := tempDir + '\' + threadID;
if not DirectoryExists(newPrivateDir) then
ForceDirectories(newPrivateDir);
Then when printing...
FilesDIR := gServerController.FilesDIR + '\temp\' +
WebApplication.AppID;
UserSession.ppReport1.TextFileName := FilesDIR + '\Licence.PDF';
UserSession.ppReport1.DeviceType := 'PDFFile';
UserSession.ppReport1.Print;
LWindowName := 'Report';
LOptions := 'scrollbars=yes,width=400,height=600';
FilesURL := gServerController.FilesURL + 'temp/' + WebApplication.AppID
+ '/Licence.PDF';
AddToInitProc('NewWindow("'+FilesURL+'","","");');
or
AddToInitProc('NewWindow("'+FilesURL+'","'+LWindowName+'","'+LOptions+'
");');
And in the ServerController component make sure the AllowSubFolders
property is set to true.
Cary.