|
|
|
|
|
- Overview
- How to?
- Generating a PDF file on the Web server
- Displaying the PDF file
- Deleting the PDF file
- Example
Displaying a report in PDF format in the browser of the Web user
To display a report in PDF format in the browser of the Web user, you must: - generate the PDF file on the Web server.
- display the generated file in the browser of Web user. The display of the file can be:
- immediate.
- requested by the web user (click performed on a link for example).
- delete the PDF file from the Web server.
Generating a PDF file on the Web server To generate a PDF file on the Web server: - Create a unique name for the PDF file to be generated. The creation directory of this file must be accessible in read/write (the directory of the data files or the "<MyProject>_WEB" directory of the site for example).
For details on how to create a unique file name, see Defining a unique name for the generated file. - Configure the print destination with iDestination associated with the iPDF constant (print in a PDF file).
- Specify the name of the report to print in iPrintReport.
The PDF file is created on the Web server.
Displaying the PDF file The display of the file can be: - immediate.
- requested by the web user (click performed on a link for example).
To automatically display the file generated in the browser of the Web user, all you have to do is use FileDisplay. To display the generated file upon request, you must: - use the FileDisplay function.
- modify the URL of the control that displays the PDF file (URL property of a button or link for example).
- ...
Deleting the PDF file To reduce the disk space occupied by the reports in PDF format on the Web server, we advise you to delete the unused reports on a regular basis. You can delete the report once it has been displayed or you can create a procedure used to delete the reports created during the day for example. The "RPT_InvoicePDF" report is displayed in PDF format on the computer of the Web user. The "ShowInvoice" button is used to: - generate the PDF file in the "<MyProject>_WEB" directory of the site.
- show the report in PDF format.
- delete the report in PDF format once it has been viewed.
In this example, the server click code of the "ShowInvoice" button is as follows: // Generate a unique PDF file name AFile is string  AFile = fWebDir() + "\" + DateSys() + TimeSys() + ".pdf" // Configure the destination of the print iDestination(iPDF, AFile) // Print the RPT_InvoicePDF report iPrintReport(RPT_InvoicePDF) // Send the file to the browser FileDisplay(AFile, "application/pdf") // Delete the file fDelete(AFile)
Remark: The PDF file can be directly opened from a button or from a link. Simply change the control action with the URL property: // Generate a unique PDF file name  AFile is string  AFile = fWebDir() + "\" + DateSys() + TimeSys() + ".pdf" // Configure the destination of the print iDestination(iPDF, AFile) // Print the RPT_InvoicePDF report iPrintReport(RPT_InvoicePDF) // Retrieve the name of the PDF file FileName is string  FileName = fExtractPath(AFile, fFile + fExtension) // Modify the action of the Link control that will open the PDF file LINK_PDFLink.URL = "/" + FolderWeb() + "/" + FileName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|