Lesson 3a: Previewing reports using thumbnails

Before rushing into viewing and scheduling, you will want to take a look at an interesting feature in Crystal Enterprise: the ability to preview a report using thumbnails. It is possible to request the server to take a snapshot of the first page of the report and return it to the browser as an image file. This image can then be displayed as part of the Report Details page.

To retrieve a thumbnail, a separate page needs to be created since the code that writes an image to the screen erases any text that may have previously been there.

You can create a thumbnail by following these steps:

  1. Query the APS for the report whose thumbnail is required.
  2. Use the PluginInterface property to get a Report object with which information about the report can be retrieved.
  3. Check to see if the report's thumbnail has been enabled, and if it is, use the Picture property to retrieve the thumbnail.
  4. Print the thumbnail on the page.

Note:    You can generate a thumbnail image of a report when the report is created. If a thumbnail has been generated with the report, and if the EnableThumbnail property is True, a thumbnail image of the report will be available for retrieval. If it is False, then no thumbnail will be available.

Using the PluginInterface

Generally speaking, the result of a query is an InfoObjects collection that may contain various objects like reports or folders. The items in this collection are returned as InfoObjects, but each InfoObject may expose a different interface, depending on what features it supports. The PluginInterface property makes it easier to communicate with one of these objects by providing a means to query for a specific interface, which is something that normal Microsoft Active Scripting does not provide.

Example

Dim Query

Query = "Select * From CI_INFOOBJECTS Where SI_ID = " & ID


Dim Res

Dim Obj

Dim RI


Set Res = IStr.Query(Query)

If Res.Count > 0 Then

    Set Obj = Res.Item(1)

    Set RI = Obj.PluginInterface

In this particular case, the PluginInterface property returns the interface for the Report object, and this interface is used to retrieve thumbnail information for the report you selected. For more information on the Report object's properties and methods, Report Object.

Retrieving thumbnail images

You can use the Picture Property to retrieve different types of images.To retrieve a thumbnail, use the following setting: Picture(4).


Dim TN  

If (RI.EnableThumbnail) then

        'Retrieve the thumbnail picture.

        TN = Obj.Picture(4)

        If (Err.Number = 0) then

            Response.ContentType = "image/jpeg"

            Response.BinaryWrite TN

        Else

            Response.Redirect "images/rpt_tn.gif"

        End If

    Else

        Response.Redirect "images/rpt_tn.gif"

    End If



Note that if the thumbnail for the report has not been enabled, then a generic image named rpt_tn.gif is put in its place.

Printing thumbnails

Using the thumbnail function is tricky since it erases all of the text on the screen. To use it, you must reference the entire file in an HTML image tag.

<IMG SRC='thumbnail.csp?ReportID=" & CurrentReportID & " '>"

This will cause the image on the thumbnail.csp page to be printed on the page that called it.

End of lesson

You've reached the end of this lesson. To see a full version of a CSP page that retrieves a thumbnail image, see Thumbnail.csp

Go to next step:

Lesson 3b: Viewing reports



Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com