- How to?
- Generating a PDF file on the Web server
- Downloading the PDF file
- Deleting the PDF file
Downloading a report in PDF format on the computer of the Web user
To propose to download a report in PDF format on the computer of the Web user, you must:
- generate the PDF file on the Web server.
- propose to download the generated file on the computer of the Web user.
- 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.
Downloading the PDF file
To propose to download the generated file on the computer of the Web user, use FileDisplay
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, for example, remove the report once it has been downloaded or create a procedure used to erase the reports generated during a day.
The "RPT_OrderPDF" report is a report in PDF format proposed for download.
The "BTN_DownloadOrder" button is used to:
- generate the PDF file in the "<ProjectName>_WEB" directory of the site.
- propose to download the report in PDF format.
- delete the PDF report once it is downloaded.
In this example, the server click code of "BTN_DownloadOrder" button is as follows:
// Generate a unique PDF file name
AFile is string = fWebDir() + "\" + DateSys() + TimeSys() + ".pdf"
// Configure the destination of the print
// Print the RPT_OrderPDF report
// Propose to download the file
// The file name proposed by default will be "Order.pdf"
FileDisplay(AFile, "application/pdf", "Order.pdf")
// Delete the file