Class Formats

All Implemented Interfaces:
AutoCloseable

public class Formats extends ChilkatObject
<section class="formats-summary">

A collection of data-format operations, starting with barcode and QR code generation.

Chilkat.Formats is not string, number or date display formatting. It groups operations on well-defined data formats behind a small number of JSON-driven methods, so the class can grow by adding a method per format family without adding a public class for each feature. Introduced in v11.7.0 with the barcode feature methods Barcode and QrCode.

QR Code generation

Versions 1–40, error-correction levels L/M/Q/H, automatic or explicit version and mask, numeric/alphanumeric/byte modes, ECI, structured append.

Precise rendering

Integer-pixel modules, px/mm/in/pt units with DPI, quiet zone, padding, rotation, colors with opacity, caption text, size limits with shrink-to-fit.

PNG or SVG output

Returned inline as base64 or SVG text, or written to files (numbered file sets for structured append). Optional module bit-matrix and reusable definition.

Measure and validate

measure reports exact geometry without rendering; validate checks a request; capabilities describes what the build supports.

One calling convention: every operation is method(op, jsonIn, jsonOut). Requests are checked strictly (unknown options are rejected, not ignored) and every failure has a stable error code with the JSON Pointer of the offending member.

See the Barcode / QR Code Generation Overview for the complete documentation with examples and sample images.

</section>

Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when done; an unclosed instance is freed when it becomes unreachable.

See Also:
Online reference
  • Constructor Details

    • Formats

      public Formats()
      Creates a new Formats object.
  • Method Details

    • barcode

      public void barcode​(String op, JsonObject jsonIn, JsonObject jsonOut)
      Runs one barcode operation and returns the result as JSON. op is the operation: "generate" (encode the payload, lay out the symbol and render a PNG or SVG), "measure" (encode and lay out only, reporting the exact geometry and whether the symbol fits), "validate" (examine a request's definition, capacity or layout) or "capabilities" (describe the symbologies, operations, formats and limits this build implements). jsonIn is the request: it names the symbology (currently "qr"), the payload (text or base64 binary) and optional encoding, render, output and limits groups. jsonOut is replaced with the response. Every response carries errors[] and warnings[]; a successful "generate" also returns symbols[] (the encoding actually selected), measurements[] (pixel geometry) and outputs[] (the image as base64 or SVG text, or the path of the file written).

      Returns true when the operation completed successfully. Returns false when the request was rejected or execution failed; errors[0] then holds a stable code, the JSON Pointer path of the offending request member and a message.

      The request and response vocabulary (payload types, QR version, error correction, mask, ECI, structured append, module size and physical units, quiet zone, rotation, colors, captions, PNG/SVG output, file writing, limits and error codes) is documented in full, with examples and sample images, at the links below.

      Parameters:
      op - the op argument (not null)
      jsonIn - the jsonIn argument (not null)
      jsonOut - the jsonOut argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • qrCode

      public void qrCode​(String op, JsonObject jsonIn, JsonObject jsonOut)
      The same as Barcode with the symbology defaulting to "qr", so the smallest request is { "payload": { "text": "..." } }. op is the operation ("generate", "measure", "validate" or "capabilities"), jsonIn the request and jsonOut the response. Identical requests to QrCode and Barcode produce identical results; a request naming a symbology outside the QR family is rejected.

      Generates QR Code (Model 2) symbols in versions 1-40 with error-correction levels L, M, Q and H, automatic or explicit version and mask selection, numeric, alphanumeric and byte modes, optional ECI, and structured append of up to 16 symbols. Output is PNG or SVG, returned inline (base64 or SVG text) and/or written to files.

      Returns true when the operation completed successfully, otherwise false with the reason in errors[0] of jsonOut (code, JSON Pointer path and message). See the links below for the complete documentation of every option, with examples and sample images.

      Parameters:
      op - the op argument (not null)
      jsonIn - the jsonIn argument (not null)
      jsonOut - the jsonOut argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why