Sample code for 30+ languages & platforms
Java Requires Chilkat v11.7.0+

Get the QR Code Capabilities of the Chilkat Version in Use

See more QR Code Examples

Demonstrates the capabilities operation, which describes what the installed version of Chilkat can do: the range of QR versions, the error-correction levels, the operations, the image formats and the limits. A program can check for a feature here instead of testing for a Chilkat version number. The request can be an empty JSON object.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkJsonObject json = new CkJsonObject();
    CkFormats fmt = new CkFormats();
    CkJsonObject jsonOut = new CkJsonObject();
    success = fmt.QrCode("capabilities",json,jsonOut);
    if (success == false) {
        System.out.println(fmt.lastErrorText());
        return;
        }

    System.out.println("Chilkat version: " + jsonOut.stringOf("productVersion"));
    System.out.println("symbology: " + jsonOut.stringOf("symbologies[0].id"));
    System.out.println("QR versions: " + jsonOut.IntOf("symbologies[0].encoding.version.min") + " to " + jsonOut.IntOf("symbologies[0].encoding.version.max"));
    System.out.println("structured append, most symbols: " + jsonOut.IntOf("symbologies[0].structuredAppend.maxSymbols"));

    int i;
    int n;
    n = jsonOut.SizeOfArray("symbologies[0].encoding.errorCorrection");
    for (i = 0; i <= n - 1; i++) {
        jsonOut.put_I(i);
        System.out.println("error correction: " + jsonOut.stringOf("symbologies[0].encoding.errorCorrection[i]"));
        }

    //  The operations this version implements.
    n = jsonOut.SizeOfArray("operations");
    for (i = 0; i <= n - 1; i++) {
        jsonOut.put_I(i);
        if (jsonOut.BoolOf("operations[i].available") == true) {
            System.out.println("operation: " + jsonOut.stringOf("operations[i].name"));
            }

        }

    n = jsonOut.SizeOfArray("imageFormats.output");
    for (i = 0; i <= n - 1; i++) {
        jsonOut.put_I(i);
        System.out.println("image format: " + jsonOut.stringOf("imageFormats.output[i]"));
        }

    System.out.println("default timeout: " + jsonOut.IntOf("limits.timeoutMs.default") + " ms");
    System.out.println("default largest image: " + jsonOut.IntOf("limits.maxPixels.default") + " pixels");

    //  Sample output:

    //  Chilkat version: 11.7.0
    //  symbology: qr
    //  QR versions: 1 to 40
    //  structured append, most symbols: 16
    //  error correction: auto
    //  error correction: L
    //  error correction: M
    //  error correction: Q
    //  error correction: H
    //  operation: generate
    //  operation: measure
    //  operation: validate
    //  operation: capabilities
    //  image format: png
    //  image format: svg
    //  default timeout: 10000 ms
    //  default largest image: 16777216 pixels
  }
}