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

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

    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');

Text::QRCode is used to encode QR codes.

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

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

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%)
  • 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.

2023-09-29 perl v5.36.0