Search code examples
node.jsangulartypescriptqr-codeurl-shortener

Shorten A String in Angular/Typescript And Expand Later When Using It


I have a string that is 928 characters that I am using to create a qr code for. The issue I am having is that, although the QR code scans fine on Iphone, android devices seem to struggle detect it. I believe this is due to the size of the QR code. I wanted to know if there was a way I could truncate that 928 character string to under 50 characters and then expand it when I use it after scanning the QR Code. Upon researching, I found many QR question and a lot of questions on how to shorten text, but nothing specifically relating to my question.

The QR HTML is:

<qrcode
        [qrdata]="qrUrl"
        [allowEmptyString]="true"
        [attr.ariaLabel]="'QR Code image with the following content...'"
        [cssClass]="'center'"
        [colorDark]="'#000000ff'"
        [colorLight]="'#ffffffff'"
        [elementType]="'canvas'"
        [errorCorrectionLevel]="'M'"
        [attr.imageSrc]="currentUser.imageData ? currentUser.imageData : './assets/default-logo.png'"
        [attr.imageHeight]="75"
        [attr.imageWidth]="75"
        [margin]="4"
        [scale]="1"
        [title]="'A custom title attribute'"
        [width]="300"
      ></qrcode>

Solution

  • Changing the error correction to L fixed the issue.