Skip to main content

How to Create a QR Code in Crystal Reports

Creating QR codes in SAP Crystal Reports is a great way to provide interactive content in your reports, such as links to websites, product information, or contact details (vCards).

This tutorial will guide you through the process of generating QR codes in your reports using QuickChart.

Step 1: Set up your Crystal Report

First, let's get your Crystal Reports environment set up and ready to go.

  1. Open Your Report: Start by opening the report you want to add a QR code to in Crystal Reports.
  2. Identify or Create the Data Source: Make sure your report is connected to a data source that contains the data you want to encode in the QR code. This could be a database, a spreadsheet, or any other data source supported by Crystal Reports.

Step 2: Create a formula to generate the QR Code URL

You will use a formula to dynamically generate the URL that creates the QR code image for each record in your report.

  1. Go to the Field Explorer: In Crystal Reports, navigate to the "Field Explorer" on the right-hand side. If you don't see it, you can enable it from the View menu.

  2. Right-Click on 'Formula Fields': Choose "New" to create a new formula field.

  3. Name Your Formula: Give your formula a meaningful name, such as QRCodeURL.

  4. Enter the Formula: In the formula editor, enter the following formula. This formula constructs a URL that generates a QR code for the data in your {QrCodeData} field. Be sure to replace {QrCodeData} with the actual field you want to encode in the QR code.

    "http://nossl.quickchart.io/qr?size=150&text=" & ToText({YourFieldNameHere}, 0, "")

    Replace {YourFieldNameHere} with the field from your data source containing the data you want to encode in the QR code.

Example

Here's an example of how the formula would look in Crystal Reports:

QR Code Formula

In this example, the {QrCodeData} field contains the URL "https://example.com". When the report is generated, the QR code will encode this URL, and scanning the QR code will direct users to the specified website.

Customization

You can customize the appearance of the QR code by modifying the parameters in the QuickChart API URL:

  • size: Adjust the size of the QR code. The value is in pixels, and the "r" suffix indicates a rounded QR code.
  • margin: Set the margin around the QR code. The value is in pixels.
  • text: Specify the data to be encoded in the QR code. Make sure to URL-encode the text if it contains special characters.

See documentation for more customization options.

  1. Save and Close: Save the formula and close the formula editor.

Step 3: Add the QR Code to your report

Now that you have a formula to generate the QR code URL, you can add it to your report as an image.

  1. Insert a Picture: In the Crystal Reports designer, go to the Insert menu and select Picture. Insert any placeholder image into your report; this will be replaced by the QR code.
  2. Set the Graphic Location: Right-click on the image you just inserted and select "Format Graphic." Go to the "Picture" tab and click on the formula button next to "Graphic Location."
  3. Use the QR Code URL Formula: In the formula workshop that opens, double-click on the QRCodeURL formula you created earlier to insert it into the "Graphic Location" formula. This tells Crystal Reports to use the QR code image generated by the QuickChart API URL as the image source.
  4. Save and Close: Save the changes and close the "Format Graphic" dialog.

Step 4: Preview and adjust

  • Preview Your Report: Now, preview your report. You should see the QR codes generated and displayed for each record in your report.
  • Adjust as Needed: You may need to adjust the size and placement of the QR code images in your report to fit your design needs.

Need help?

You've successfully added dynamic QR codes to your Crystal Reports using QuickChart!

Questions? Visit our community.