Skip to content

ShashankN/qrcode-terminal

Repository files navigation

QRCode terminal

Print QR Codes straight in your terminal

Usage

Add maven dependency

<dependency>
    <groupId>io.github.shashankn</groupId>
    <artifactId>qr-terminal</artifactId>
    <version>1.0.0</version>
</dependency>

Generate full size ASCII block QR Code

QRCode.from("https://www.google.com").generate();

half block qrcode

Generate smaller 'half blocks' in the terminal

QRCode.from("https://www.google.com").generateHalfBlock();

half block qrcode

Specify other params

QRCode.from("https://www.google.com")
        .withSize(30,30)
        .withMargin(3)
        .withErrorCorrection(ErrorCorrectionLevel.H)
        .generate();

Specify your own palette/characters

FullBlockPalette customPalette = new FullBlockPalette("\033[40m  \033[0m", "\033[47m  \033[0m", System.lineSeparator());
QRCode.from("https://www.google.com")
        .withSize(30,30)
        .withMargin(3)
        .withErrorCorrection(ErrorCorrectionLevel.H)
        .generateWithPalette(customPalette);
      
HalfBlockPalette customPalette =  new HalfBlockPalette(" ", "▄", "▀", "█",System.lineSeparator());
QRCode.from("https://www.google.com")
        .withMargin(3)
        .withErrorCorrection(ErrorCorrectionLevel.H)
        .withSize(30,30)
        .generateHalfBlockWithPalette(customPalette);

Releases

No releases published

Packages

No packages published

Languages