Typeset.sh
HomeNewsDemoPricing
  • Getting started
    • Installation
    • Using typeset.sh
    • First template
    • CSS and paged media
      • Page counters
      • Page selectors
      • Page groups
      • Running elements
      • Bleed area
    • Convert from URL
    • Document Metadata
    • Changelog
  • Advanced guides
    • QR codes
    • Save handlers
    • Error handling
    • Signing a PDF
    • PDF Standards
      • ZUGFeRD
      • PDF/A
      • PDF/UA
      • PDF/X-4
    • Color profiles
    • JavaScript
    • Common Object/Classes
      • createPdf function
      • HtmlToPdf
      • Result Object
Powered by GitBook
On this page
  1. Advanced guides

QR codes

PreviousChangelogNextSave handlers

Last updated 2 years ago

A QR code (Quick Response code) is a two-dimensional barcode that can be scanned using a smartphone camera or QR code reader. QR codes are similar to traditional barcodes, but they can store much more information and can be scanned much more quickly.

They are often used to store website URLs, contact information, or other types of data that can be easily accessed by scanning the code.

Codes can be placed on business cards, brochures, advertisements, or other marketing materials. They can also be used in other ways such as for mobile payments, ticketing, and much more. They can also be used to track inventory and assets in industries such as manufacturing and logistics.

CSS and HTML do not include built-in support for QR codes, therefore, it must be obtained from a separate package that needs to be imported specifically if you wish to use it.

To install it, use composer and require typesetsh/qr-code-element.

composer require typesetsh/qr-code-element

After installation, you can include the qr-code element in your HTML. This element supports the alt attribute as well as the icon-src and icon-size attributes. These can be used to place and adjust the size of an icon in the center of your QR code. The size is represented as an integer, where 1 equals one block size (a single block-bit, so to speak). The content within the qr-code element represents the data that will be encoded in the QR code.

<qr-code icon-src="icon.png" icon-size="3">DATE_GOES-HERE</qr-code>

Please be aware that white spaces are not automatically removed. If you are adding multi-line content for encoding, make sure to avoid using tabs or white spaces for code indentation, as these will also be encoded in the QR code.

Attributes

Attribute
Default
Description

data-error-correction-level

Q

Possible values: L: ~7% correction M: ~15% correction Q: ~25% correction H: ~30% correction

data-encoding

UTF-8

Valid encoding, default UTF-8

icon-src

Any image url

icon-size

0

The size of the icon in bit unit. 1 equals the size of 1 square.

QR Code (Live Demo)
Logo