QR Code Data Encoding and Data Modes in SSRS
QR Codes support multiple data modes to ensure efficient encoding of different types of data. This is critical for SSRS reports that handle diverse data from the Report Server Database.
All data mode settings must be configured in the Report Item Property panel of the SSRS Image item. The C# code must match these settings to avoid encoding errors in SSRS report rendering.
The five key data modes supported are:
All data mode settings must be configured in the Report Item Property panel of the SSRS Image item. The C# code must match these settings to avoid encoding errors in SSRS report rendering.
The five key data modes supported are:
- QRCodeDataMode.Auto: The barcode library automatically selects the optimal data mode based on the input data. This setting is configured in the SSRS Report Item Property. It is the most commonly used mode for SSRS reports, as it adapts to different data types from the Dataset (e.g., numeric order IDs, alphanumeric URLs).
- QRCodeDataMode.Numeric: For encoding numeric data (digits 0 - 9) only. Ideal for SSRS reports displaying numerical values (e.g., order IDs).
- QRCodeDataMode.AlphaNumeric: For alphanumeric data (digits 0 - 9, uppercase letters A-Z, and special characters: space, $ % * + - . / :).
- QRCodeDataMode.Byte: For byte data (default: ISO/IEC 8859-1). Used for non-English text, binary data, or Unicode content.
- QRCodeDataMode.Kanji: For encoding Kanji characters (JIS X 0208), compacted into 13 bits per character.
Maximum Data Length for QR Codes in SSRS
The maximum data length per QR Code depends on two factors: the data mode and the QR Code Version (1-40). Version 40 (the largest size) supports the maximum data capacity.
This is suitable for SSRS reports requiring encoding of large amounts of data. Examples include detailed product information or multiple Dataset Fields (e.g., customer name, address, and contact details from the Report Server Database).
For Version 40-L (the largest size), the maximum character limits are:
This is suitable for SSRS reports requiring encoding of large amounts of data. Examples include detailed product information or multiple Dataset Fields (e.g., customer name, address, and contact details from the Report Server Database).
For Version 40-L (the largest size), the maximum character limits are:
- Numeric data: 7,089 characters
- Alphanumeric data: 4,296 characters
- Byte data: 2,953 characters
- Kanji data: 1,817 characters
Note: If your SSRS report requires encoding more data than the maximum limit for a single QR Code, use QR Code Structured Append mode. This mode is configured in both C# and the SSRS Report Item Property. It allows splitting large data into up to 16 QR Code symbols, which can be scanned sequentially to retrieve the full data. This is useful for SSRS reports with extensive Dataset data, such as detailed audit logs from the Report Execution Log.
Encoding Special Text Formats in SSRS QR Codes
SSRS reports often need to encode special text formats. These include non-printable ASCII characters, Unicode text, GS1 data, and Kanji characters. These formats are common in logistics, healthcare, and international SSRS projects.
Below are step-by-step guides to implementing these scenarios using C#. All property settings are configured in the SSRS Report Item Property panel to ensure compatibility with SSRS components.
Below are step-by-step guides to implementing these scenarios using C#. All property settings are configured in the SSRS Report Item Property panel to ensure compatibility with SSRS components.
Non-Printable ASCII Characters
Non-printable ASCII characters (e.g., Carriage Return [CR], Line Feed [LF]) are often used in SSRS reports for data formatting or control. They are useful for structuring data from the Dataset (e.g., separating multiple Fields in a single QR Code).
To encode these characters into QR Codes for SSRS reports:
To encode these characters into QR Codes for SSRS reports:
- Set the ProcessTilde property to true (enables "~" as a special character for encoding ASCII values).
- Convert the non-printable character to its three-digit ASCII value (e.g., [CR] = 013) and prefix it with "~".
- In SSRS Report Item Property: Set the "Process Tilde" property to true and ensure the DataMode is set to Auto.
Note: If ProcessTilde is not enabled, the "~" character will be treated as normal text. This leads to encoding errors and incorrect QR Code data in the SSRS report.
Unicode Text (e.g., Thai, Arabic)
QR Codes do not support Unicode text by default. For SSRS reports requiring encoding of non-English text (e.g., Thai, Arabic, Chinese), use the Byte data mode and UTF-8 encoding. This is essential for SSRS reports with international audiences, such as those distributed via Email Subscription.
To encode Unicode text into QR Codes for SSRS reports:
To encode Unicode text into QR Codes for SSRS reports:
- Convert the Unicode text to a byte array using UTF-8 encoding, then format each byte as "~ddd" (three-digit value).
- Set ProcessTilde to true and DataMode to QRCodeDataMode.Byte.
- In SSRS Report Item Property: Set DataMode to Byte and Process Tilde to true.
GS1 QR Code
GS1 QR Codes encode GS1 data elements (Application Identifier [AI] + data).
They are common in SSRS reports for logistics, retail, and healthcare. Examples include product expiry dates, lot numbers, and serial numbers from the Report Server Database.
To generate GS1 QR Codes in SSRS:
To generate GS1 QR Codes in SSRS:
- In SSRS Report Item Property: Set the "FNC1 Mode" to "First Position" and DataMode to Auto.
- You can bind the GS1 data to a Calculated Field in the SSRS Dataset. This dynamically generates the data string based on other Dataset Fields.
- Format the data as "(AI)data" (e.g., "(17)050101(10)ABC123", where (17) = Expiry Date, (10) = Lot Number). The data can be retrieved from the SSRS Dataset Fields.
Note: Ensure the AI code and data length comply with GS1 standards. Incorrect formatting will make the QR Code unreadable by GS1 scanners, which is critical for SSRS reports used in supply chain management.
Kanji Characters
To encode Kanji characters in SSRS QR Codes (common in Japanese-language SSRS reports), use the Kanji data mode and special formatting. This is suitable for SSRS reports targeting Japanese users, such as those deployed in SharePoint Mode for regional teams.
To encode Kanji characters in SSRS QR Codes:
To encode Kanji characters in SSRS QR Codes:
- Format Kanji characters as "~9ddddd" (ddddd = decimal value of the SJIS code).
- In SSRS Report Item Property: Set DataMode to Kanji and Process Tilde to true.
Customizing QR Code Dimensions and Appearance in SSRS
All QR Code dimension and appearance settings are configured in the SSRS Report Item Property panel for the Image item, with corresponding C# code to match:
QR Code Dimensions
The QR Code is a square image, so its width and height are the same. You can customize the size to fit the SSRS report layout. This is important for Paginated Reports with fixed page sizes or Mobile Reports optimized for different devices.
In SSRS Report Item Property: Set the "Barcode Width" property to define the square QR Code size (e.g., 200 pixels).
In SSRS Report Item Property: Set the "Barcode Width" property to define the square QR Code size (e.g., 200 pixels).
Quiet Zone
The quiet zone is an empty space around the QR Code. It is required for scanners to correctly identify the QR Code. This is a critical setting for SSRS reports used in physical printing (e.g., labels, invoices).
Configure this in SSRS Report Item Property
Configure this in SSRS Report Item Property
- In SSRS Report Item Property: Set LeftMargin, RightMargin, TopMargin, and BottomMargin (e.g., 50 pixels each).
Note: Missing or insufficient quiet zones will cause QR Code scanning failures. This is a common error in SSRS reports, especially when the Image item is placed too close to other report elements like Tablix or Page Header.
Colors
Customize the QR Code colors (bar color and background color) to match the SSRS report's visual style. This enhances brand consistency and readability, especially for SSRS reports shared via the Web Portal or Email Subscription.
Customize QR Code colors (bar and background) in SSRS Report Item Property.
Customize QR Code colors (bar and background) in SSRS Report Item Property.
- In SSRS Report Item Property: Set "Fore Color" (bar color) and "Back Color" (background color).
Note: Avoid using light colors for bars or dark colors for the background. This reduces contrast and makes the QR Code hard to scan, especially when the report is exported to PDF via SSRS Rendering Extensions.
Advanced QR Code Settings in SSRS
Advanced settings enhance the functionality and flexibility of QR Codes in SSRS reports. These include error correction, version control, and structured append. All these settings are configured through the SSRS Report Item Property panel.
They ensure the QR Codes meet the specific requirements of your SSRS project, such as data integrity, scalability, and compatibility with different environments.
Configure advanced QR Code settings in SSRS Report Item Property to enhance functionality.
They ensure the QR Codes meet the specific requirements of your SSRS project, such as data integrity, scalability, and compatibility with different environments.
Configure advanced QR Code settings in SSRS Report Item Property to enhance functionality.
Error Correction Level (ECL)
QR Codes support four error correction levels. These levels determine the ability to recover data if the QR Code is damaged (e.g., smudged, scratched). Configure this setting based on the SSRS report's usage scenario.
For example, reports used in harsh logistics environments require higher error correction than internal enterprise reports.
ECL configured in SSRS Report Item Property:
For example, reports used in harsh logistics environments require higher error correction than internal enterprise reports.
ECL configured in SSRS Report Item Property:
- QRCodeECL.L: 7% error correction (default)
- QRCodeECL.M: 15% error correction
- QRCodeECL.Q: 25% error correction
- QRCodeECL.H: 30% error correction
Note: Higher error correction levels increase the QR Code size. Balance scannability and size based on your SSRS report layout, especially for Mobile Reports with limited screen space.
QR Code Version
QR Codes have 40 versions (1-40). Version 1 is the smallest (21x21 modules), and Version 40 is the largest (177x177 modules). The version is determined by the data amount and error correction level.
Set the version in SSRS Report Item Property.
Set the version in SSRS Report Item Property.
Structured Append Mode
For SSRS reports requiring encoding of large amounts of data (exceeding the maximum length of a single QR Code), use Structured Append mode. This mode splits the data into up to 16 QR Code symbols.
It is useful for SSRS reports with extensive Dataset data, such as detailed product catalogs or audit logs from the Report Execution Log.
Configure in SSRS Report Item Property
It is useful for SSRS reports with extensive Dataset data, such as detailed product catalogs or audit logs from the Report Execution Log.
Configure in SSRS Report Item Property
- In SSRS Report Item Property: Enable "Structured Append" and set the corresponding values.
Note: All symbols must be scanned in order to retrieve the full data. Ensure the SymbolCount and SymbolIndex are correctly configured for all symbols. This is critical for SSRS reports used in data-intensive scenarios.
Extended Channel Interpretation (ECI) Mode
ECI mode allows changing the character set (default: ISO/IEC 8859-1). Configure in SSRS Report Item Property
- In SSRS Report Item Property: Set "ECI Value" and enable "Process Tilde".
Summary
By following this guide, you can successfully integrate dynamic QR Code generation into your SSRS reports using C# .NET. This integration enhances the functionality of SSRS reports, enabling scenarios such as data visualization, label printing, and quick data access. It also ensures compatibility with SSRS components and best practices, making your SSRS project more efficient and reliable.
Common Asked Questions
What does QR stand for in code?
QR stands for "quick response", and QR Code is a 2-dimensional matrix barcode. The QR Code stores data information both horizontally and vertically.
The QR Code is designed for high speed reading barcode.
OnBarcode SQL Server Reporting Services QR Code Generator library supports QR Code generation in Visual Studio SSRS report designer,
and preview QR Codes in SSRS report viewer in WinForms, ASP.NET Core projects.
What is the maximum data in a QR code?
A standard QR Code can store up to three kilobytes (KB) of data.
A QR Code symbol with version 40-L can hold the following maximum data characters:
- numeric data: 7,089 characters
- alphanumeric data: 4,296 characters
- byte data: 2,953 characters
- Kanji data: 1,817 characters
What is the smallest I can make a QR code in SSRS reports?
The recommended smallest size of QR Code is 2 x 2 cm, and they will be scanned and read by cameras from smartphones (iOS or Android).
If the generated QR Code is for QR Code scanners, the minimum size for a QR Code is 1 x 1 cm.
Using .NET SQL Server Reporting Services QR Code Generator library, you can create and customize the printed QR Code dimension size in SSRS report designer in Visual Studio .NET.
Using .NET SQL Server Reporting Services QR Code Generator library, you can create and customize the printed QR Code dimension size in SSRS report designer in Visual Studio .NET.
Does the color of a QR Code matter?
Choose whatever colors you want but always make sure the fore (bar) module and back (space) moduel colors have high contrast.
We suggest at least 70% darker to ensure reliable camera scanning, and always scan and test your QR code using the camera in your smartphone.
You can customize the QR Code bar and space colors in SSRS report designer using Visual Studio .NET IDE.
You can customize the QR Code bar and space colors in SSRS report designer using Visual Studio .NET IDE.
How to create a QR Code for a picture?
To create a QR code from a photo or an image in SSRS reports
- Convert the photo image raw data into byte array, and store in the database
- Create, insert a QR Code barcode item in SSRS report designer
- Set the QR Code data mode as byte
- Print and output QR Code in the SSRS report. You can preview the report in report viewer.
What is the difference between a barcode and a QR Code?
Barcode is usually known as 1d or linear barcode symbology, which can store limited number of characters.
QR Code or Quick Response Code, is a type of two-dimensional code, which will store characters horizontally and vertically, and a QR Code can hold more than 4,200 alphanumeric characters.
Using OnBarcode SQL Server Reporting Services Barcode Generator library, you can create, insert QR Code (standard, GS1, Micro, Macro versions) and other 20+ 2d, 1d barcodes such as Code 128, Data Matrix, EAN/UPC barcodes in SSRS report designer and view QR Code and barcodes in report viewer using Visual Studio .NET.
Using OnBarcode SQL Server Reporting Services Barcode Generator library, you can create, insert QR Code (standard, GS1, Micro, Macro versions) and other 20+ 2d, 1d barcodes such as Code 128, Data Matrix, EAN/UPC barcodes in SSRS report designer and view QR Code and barcodes in report viewer using Visual Studio .NET.
