Uploading objects to FastReport VCL using the http and https protocols

Uploading objects to FastReport VCL using the http and https protocols

One of the key tasks of a report generator is data retrieval. Most often, databases are used to store and retrieve data. But what if it is remote cloud storage, which is used to store certain data? How to upload a company logo via http to a report to ensure that it is always up-to-date?

To solve these problems in FastReport VCL 2021.3 we have added support for protocols and the function of loading data through protocols into objects such as: Maps, Picture, Text, PDF object, HTML object. Some objects have a new DataLink property that includes additional properties for handling links. Such links always start with the schema name followed by a separator. Example <schema>: [//path]. In most cases, the scheme is protocols such as http and https.

Data loading via links in FastReport VCL

FastReport VCL is based on a modular architecture, the functionality of http and https is no exception, and it is included in a separate package along with Internet transports. Therefore, for links to work via the http and https protocols, you need to connect the frxTransportHTTP module in the uses section of the application or add one of the Internet transports to the application form.

List of Internet transports on the component palette

 

Important! The following Open SSL libraries are required for the https protocol to work: ssleay32.dll and libeay32.dll. You can find them in the directory with the main demo application.

Let's start the report designer and create a new report. Then add the "Report Title" band on the report page and a picture object to it. The report should look as follows:

An example of the generated report

Let’s select the "Picture" object and go to the object inspector. Find the DataLink property in the object inspector. For a quick search, you can use the filter built into the object inspector by entering the name of the desired property.

Search for the DataLink property

Let’s look at the meaning of the DataLink children properties:

Link – a link with a schema (protocol), in the format <schema>: [//path]. The data will be loaded from the specified link.

LoadingType – loading type. It indicates when the data will be loaded. It can have the following values:

[] – Empty. The data is loaded in the template editing mode, when the user clicks on the load editor. It is used if you need to retrieve data only once and store it in the template.

Load editor button in the report designer

Let's set the DataLink.Link property of the "Picture" object with a link to a picture from the website, for example. Let's execute the report.

An example of a generated report

Similarly, you can load other objects, such as: Text, Picture, Maps, HTMLView, PDFView.

The links can be used to access the Web API to get data, for example OSM maps.

Let's create a new report with the "Report Title" band and a Map object with an empty layer (You can see how to create the Map object in our documentation).

Created report with a map

Now let's select the map layer MapFileLayer1 and go to the DataLink.Link property in the object inspector. You can use the OpenStreetMap API to load OSM maps. Let's try to display the selected area in FastReport VCL. The API link will look as follows: https://www.openstreetmap.org/api/0.6/map?bbox=-6.7234%2C61.6283%2C-6.697%2C61.6379 . Insert it into the DataLink.Link property. Let's generate the report.

Report with OpenStreetMap API in a preview mode

The data from the server has been loaded into the map object automatically.

More than hyperlinks

In FastReport VCL, all schemas and protocols of the DataLink property are processed through a factory. This allows developers to expand the functionality of the application by adding new schemes and protocols without any changes in the FastReport VCL source codes. In addition, FastReport VCL automatically registers internet transports in the factory as new protocols. This enables to access private cloud storage and load data from them into a report, without transferring or storing any authorization data within the report. You can see the scheme of interaction of the DataLink property with the protocol factory below.

A diagram of the interaction of the DataLink property with the protocol factory

How to add internet transport and use links to a private Google Drive?

This can be done in just a few steps:

  1. Open the component palette with Internet transports.
  2. Add TfrxGoogleDriveIOTransport to the application form.
  3. Assign a name to the component. The name will be used as the schema protocol for the access link. In the example, we named it “GDRIVE”.

FastReport VCL

  1. Edit connection to Google Drive through the “Edit connection” menu  (see another article for more details).

FastReport VCL

  1. Run the report designer and create a report by following the steps as at the beginning of the article when you created a report with a picture.
  2. You need to specify the link to the file in Google Dive in the DataLink.Link property, but instead of the scheme (protocol) specify the name of the transport. In our case, it is “GDRIVE“. The link will look like this: GDRIVE://LogoF.PNG. Then you can execute the report.

FastReport VCL

Important! If the data is not loaded, make sure that you’ve connected to the cloud storage properly and the authorization token was saved when connecting.

Similarly, you can connect to other Internet transports. This is one of the few powerful tools that were introduced in FastReport VCL 2021.3 and which you can use to improve your projects.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot