PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Overview
  • How to proceed?
  • Generating a PDF file on the Web server
  • Displaying the PDF file
  • Deleting the PDF file
  • Example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Displaying a report in PDF format in the browser of the Web user
Overview
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.
How to proceed?

Generating a PDF file on the Web server

To generate a PDF file on the Web server:
  1. Create a unique name for the PDF file to generate. 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).
    See Defining a unique name for the generated file for more details.
  2. Configure the destination of the print with iDestination associated with the iPDF constant (print in a PDF file).
  3. 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 FileDisplay.
  • 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.
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)
Note: The PDF file can be directly opened from a button or from a link. All you have to do is modify the action of this control with ..URL:
// 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, fFileName + fExtension)
// Modify the action of the Link control that will open the PDF file
LINK_PDFLink..URL = "/" + FolderWeb() + "/" + FileName
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment