Scroll to navigation

PDF::API2::Resource::XObject::Form::BarCode::qrcode(3) User Contributed Perl Documentation PDF::API2::Resource::XObject::Form::BarCode::qrcode(3)

NAME

PDF::API2::Resource::XObject::Form::BarCode::qrcode - Generate QR codes

SYNOPSIS

    use PDF::API2;
    my $pdf = PDF::API2->new();
    my $page = $pdf->page();
    # Create a QR Code object
    my $barcode = $pdf->barcode('qr', 'This is a test');
    # Calculate the scale needed for a desired size (72pt / inch)
    my $desired_inches = 2;
    my $scale = $desired_inches * 72 / $barcode->width();
    # Place the QR Code one inch (72pt) from the bottom left corner
    $page->object($barcode, 72, 72, $scale);
    $pdf->save('qr_test.pdf');

REQUIREMENTS

Text::QRCode is used to encode QR codes.

OPTIONS

    my $barcode = $pdf->barcode('qr', $value, %options);

The following standard barcode options are supported, as described in "barcode" in PDF::API2:

  • bar_width (default: 1; unit is points)
  • bar_height (default: bar width)
  • quiet_zone (default: 4x bar width)
  • color (default: black)

The following options are specific to QR codes:

error_correction (default: L)

The QR Code Error Correction Level. Higher levels of error correction generate larger bar codes but remain scannable when parts of the code are damaged or obscured.

In increasing order of error correction, the possible values are:

  • L (7%)
  • M (15%)
  • Q (25%)
  • H (30%)
  • version (default: 0)

    If you need a specific version of QR Code, enter it here. Otherwise, the minimum version will be used that can support the encoded value.

  • mode (default: 8-bit)

    You can generate smaller QR codes if you're using a restricted character set:

  • 8-bit (typically the ISO-8859-1 character set)
  • kanji
  • alphanumeric (digits, uppercase letters, space, or "$ % * + - . / :")
  • numeric (digits)
case_sensitive (default: 1)

Whether 8-bit characters should be treated in a case-sensitive manner.

2024-06-23 perl v5.40.0