CapeSoft.Com
Clarion Accessories
NetTalk
Doc Index
Reports
CapeSoft Logo

CapeSoft NetTalk
Web Reports

Download Latest Version
Installed Version Latest Version

NetTalk WebServer - Using Reports in a Webserver Application

Introduction

There are various way to approaching printing in a WebServer application.

Firstly it should be remembered that the printing is a function of the browser. Which means that any page your application delivers is intrinsically a report. The user can click on the browser print option at any time. By careful design, and attention to the information you are presenting, you can make many "reports" obsolete.

There are times though where a specifically formatted document is necessary. In these cases HTML doesn't necessarily offer the degree of control that you need. The best option in this situation is to create a PDF file, and have the browser display this.

Since Clarion 6 Enterprise Edition contains a Report-To-PDF extension, this seems like a good place to start. You can take existing report procedures in your application, and with minor additions make it generate a PDF file, and also allow the NetTalk WebServer to send the PDF file to the browser. PDF makes an excellent format for this sort of thing because most browsers already know how to display a PDF (via the Adobe plugin) and you have 100% control over how the page will be displayed, and importantly 100% control over how it will look when printed.

If you don't have Clarion 6 EE, then there are other 3rd party tools that can be purchased that do a similar thing. NetTalk 4 includes examples of using the Clarion 6 EE functionality, as well as examples from other vendors.

Adding SoftVelocity PDF functionality to your report

Clarion 6 Enterprise Edition includes functionality to turn an existing report into a PDF file. If you only have Clarion 6 PE then this is available separately.

Example 13 (ABC), and Example 38 (Legacy) in the list of NetTalk Web Server examples are examples of doing this.

Note Legacy Templates: In order to use the SV PDF Global Extension you will need to go to Global Properties, Classes Tab, And tick on the option "Enable the use of ABC Classes. This explanation assumes you have a report procedure already, based on the normal Report template.
  1. Add the "Report to PDF Global" global extension to your application.
  2. In the report procedure, go to extensions. You'll see the report to PDF extension already there. You can set the settings for this extension as you like. (See SV docs and help files for what the extension can do). 

     
     
  3. Add the NetTalk extension NetWebReportABC to this procedure
     
  4. On the properties screen for the procedure set the Prototype to
    (<NetWebServerWorker p_web>)
    and set the Parameters to
    (<NetWebServerWorker p_web>)
     
  5. Note: Make sure the Print Preview functionality for the report is turned ON. The PDF engine requires this. The NetTalk template will suppress the actual preview though - since the preview would appear on the server (where no-one is looking.)
     
  6. Click on the Project menu and select Generate All.

Now that your report procedure is ready, all you need to do is link it from a web page.

In the example, the report procedure is called MailboxesReport. The menu for this application is in the PageHeaderTag procedure. One of the menu items there calls the report (by setting the URL to 'MailBoxesReport'. Also notice that the Target is set to '_blank' which will cause the finished PDF file to open in it's own browser window.

Adding PDF-Tools functionality to your report

An alternative to the built-in Clarion 6 PDF functionality is PDF-Tools SDK, from Tracker Software.

Example 14 in the list of NetTalk Web Server examples is an example of using this to generate the PDF files.

  1. Add the Global template "PDF-Tools Report Global Extension 3.5" to your application.
    The default settings for the extension should be fine.
     
  2. Add the "PDF-Tools Report Procedure Extension 3.5" to the report procedure you wish to add
    PDF output to. The defaults will be inherited form the Global Template. Most of the defaults are fine, however make sure the following items are set correctly:

    General Tab:
    Set FileName to !loc:PDFname

    Previewer Tab:
    Generate PDF: Yes - Always
    Show Generate PDF: No - Never 
    PDF Viewer Option: None
    Run Print Previewer: No - Never 
    Print Hardcopy: No - Never 
  3. Add the NetTalk, NetWebReportxc extension to the procedure
     
  4. On the properties screen for the procedure set the Prototype to
    (<NetWebServerWorker p_web>)
    and set the Parameters to
    (<NetWebServerWorker p_web>)
     
  5. Click on the Project menu and select Generate All.

Now that your report procedure is ready, all you need to do is link it from a web page.

In the example, the report procedure is called MailboxesReport. The menu for this application is in the PageHeaderTag procedure. One of the menu items there calls the report (by setting the URL to 'MailBoxesReport'. Also notice that the Target is set to '_blank' which will cause the finished PDF file to open in it's own browser window.

Report Progress Bars

NetTalk 6 introduces the ability to display a progress bar when a Report (or any other sort of file) is being created. This gives more feedback to the user in cases where the generation of the file may take some time. Rather than display a blank page until the file is completed, a progress bar is displayed. Once the progress bar reaches 100%, the bar is replaced with a URL which the user can click on to download the file.

Progress Bars work in conjunction with a Button control. They are designed to be used when a task is started (by a button) that may take some time to complete. This task is almost always the creation of a file, perhaps a PDF Report file, or an Excel spreadsheet, or something like that.
 
  1. First add a Progress Control to a form. Make sure the field has an Equate name, and set the timer to an appropriate number. The value is in thousandths-of-a-second so setting it to 1000 = 1 second. Bear in mind that frequent progress bar updates place a load on the server, so don't be too aggressive with this number.


  2. Second add a button to the form. This is what the user will click to "Start" the action. Set the button to be of type START, give it a name, and put some text on the button.



    On the OnClick tab set the Procedure name, and the Progress Field options.


  3. Report procedures  (with the NetTalk Report extension) will automatically include the code necessary to update the progress bar. The progress of the report is taken from the same progress bar that would normally appear if the report was called from a windows program.

    If you have a hand-coded procedure, which is generating a file, then you can add the following to it so that it also supports the progress bar.

    a)  Make sure the procedure has (NetWebServerWorker p_web) as the first parameter.

    b)  When the procedure starts make a note of the Progress Bar Name, and store this in a local variable
    loc:ProgressName = p_web.GetValue('_ProgressName_')

    c) Put the following code when your procedure starts;
    p_web.SetProgress(loc:ProgressName,1)

    d) During the creation of the file update the progress by calling
    p_web.SetProgress(loc:ProgressName,xxx)
    where xxx is a number from 1 to 99.

    e) when the file is completely generated, and ready for download call
    p_web.SetProgress(loc:ProgressName,url)
    Where url is the filename relative to the Web folder. Note this isn't the "full path" of the actual filename, only the part relative to the web folder. This name will be the URL that the user clicks on to download the generated file.

TIP: Remember a file which start its name with the characters $$$ will be deleted after a single download.

[End of this document]
Return to NetTalk Documentation Index