Rave Report PDF and Intraweb

发布时间 : 星期一 文章Rave Report PDF and Intraweb更新完毕开始阅读

We will place a tDataset and a tIwDbGrid on our page: from the Tools Palette \Access\tab, drop a tClientDataSet on the Form

set its FileName property to the path and file name of the EMPLOYEE.XML file,

and toggle Active to True

drop a tDataSource on the Form, and connect its DataSet to ClientDataSet1

from the \tIwDbGrid on the Form, and connect its DataSource to DataSource1

compile, run, type F9

the page displays the content of the Table:

3.2 - Displaying a .PDF file

Second step: how to present a .PDF file by clicking on an Intraweb link or button. The main points are

?

create a FILES/ sub directory and place the .PDFs in this folder

? create a pop-up web page by code which will display the .PDF report

Therefore

create the FILES/ sub directory in the folder containing your Intraweb

copy the previous .PDF, in our case MY_REPORT.PDF into this folder .EXE

from the \tIwButton to the Form, create its OnClick event, and use the following code: procedure TIWForm1.displaypdfClick(Sender: TObject); var l_pdf_file_name: string; l_popup_page_name: string; l_popup_page_options: string; l_pdf_url: string; begin l_pdf_file_name:= 'my_report.pdf'; l_popup_page_name:= 'the_report'; l_popup_page_options:= 'scrollbars=yes,width=400,height=600'; l_pdf_url:= WebApplication.AppURLBase+ '/files/'+ l_pdf_file_name; AddToInitProc('NewWindow(\ + l_pdf_url + '\+ l_popup_page_name + '\+ l_popup_page_options + '\); end; // displaypdfClick

compile, run, click F9, click \the report is displayed in a pop-up page:

3.3 - Generating the Report

To generate a simple .PDF report, we will use the same technique as the one used with a simple Win32 project, using atRvProject, tRvDataSetConnection, tRvSystem, tRvRenderPdf:

from the \

the tRvProject, tRvDataSetConnection, tRvSystem, tRvRenderPdf and connect them exactly as in the previous example

drop a tIwButton, and, in its OnClick event, create the .PDF file in the FILES/

subdirectory: procedure TIWForm1.CreatePdfClick(Sender: TObject); begin with RvSystem1 do begin DoNativeOutput:= false; RenderObject:= RvRenderPDF1; OutputFileName:= 'FILES\\my_report_3.pdf'; end; // with RvSystem1 RvProject1.Execute; end; // CreatePdfClick

3.4 - Multi User .PDF generation

The previous approach works, but since Rave is not thread save, when several users want to generate .PDF files, we run into race problems.

The solution recommended on the Intraweb web site is to protect the generation of the report with some synchronizing object, like a critical section, and to create the tRvDataSetConnection for each report.

Let's try this solution. There are several points to take care of

the critical section is created in the Initialization section of the Unit, and freed in the Finalization section

? if the reports are confidential, we must ensure that one User cannot read the .PDF build for another User. The easiest way to do this is by creating separate folders, using

the IntraWeb SessionId, which is a \Session, this value is retrieved using WebApplication.AppID.

? this User directory must be created before the .PDF is generated, and deleted after the use of the .PDF. We can use thetIwServerControllerBase.OnCloseSession event to perform this

?

Here is our project:

copy the previous project to a new folder, and remove the two tIwButtons and their events

联系合同范文客服:xxxxx#qq.com(#替换为@)