Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Reports in intraweb problem

edited November 2004 in General
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

Comments

  • edited November 2004
    My app is an ASPI dll. Delphi7 intraweb 7 IIS 5 Reportwriter 7.04

    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.
  • edited November 2004
    Try...

    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+'
    ");');
  • edited November 2004
    Oops, missed the bit about creating usertemp directories...

    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+'
    ");');


  • edited November 2004
    > Create the temp directories below the Files directory:
    And in the ServerController component make sure the AllowSubFolders
    property is set to true.

    Cary.
This discussion has been closed.