Skip to main content

QRFrameOptions Class

The base class for QR code frame options.

Declaration

public abstract class QRFrameOptions extends JavaObject

Remarks

The following frame options are available for QR codes:

Frame Options Description
RectangleQRFrameOptions Displays a rectangular frame around the QR code.
CornerQRFrameOptions Displays corner lines around the QR code.
PaymentServicesAustriaQRFrameOptions Displays a frame that complies with the Payment Services Austria (PSA) guidelines. This option is available only for QR EPC codes.

Refer to the following help topic for additional information: QR Code.

The following code snippet creates a QR Code barcode and customizes its encoding parameters:

import com.devexpress.drawing.*;
import com.devexpress.docs.barcode.*;
import com.devexpress.system.drawing.*;
import com.devexpress.docs.Padding;

import java.io.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {

        byte[] logoBytes = Files.readAllBytes(Path.of("images/devexpress-logo.png"));

        try (DXImage logo = DXImage.fromStream(new ByteArrayInputStream(logoBytes))) {

            // Customize QR Code parameters.
            QRCodeOptions options = new QRCodeOptions();
            options.setErrorCorrectionLevel(QRCodeErrorCorrectionLevel.H);
            options.setCompactionMode(QRCodeCompactionMode.AUTO);
            options.setVersion(QRCodeVersion.VERSION_10);
            options.setIncludeQuietZone(true);
            options.setLogo(logo);
            options.setPadding(new Padding(10));
            options.setModuleSize(10);
            options.setShowText(false);

            // Customize QR Code frame parameters.
            RectangleQRFrameOptions frameOptions = new RectangleQRFrameOptions();
            frameOptions.setPadding(new Padding(10));
            frameOptions.setFrameColor(Color.getOrange());
            frameOptions.setFrameWidth(10);
            frameOptions.setText("DevExpress");
            frameOptions.setCornerRadius(10);
            frameOptions.setTextAlignment(QRFrameTextAlignment.CENTER);
            frameOptions.setTextColor(Color.getBlack());
            frameOptions.setTextPosition(QRFrameTextPosition.BOTTOM);

            options.setFrameOptions(frameOptions);

            Path outputDir = Path.of("output");
            Files.createDirectories(outputDir);

            try (FileOutputStream fileStream = new FileOutputStream(
                    outputDir.resolve("qrcode.png").toFile());
                    BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                        barcodeGenerator.export(
                                "https://www.devexpress.com",
                                fileStream,
                                DXImageFormat.getPng());
            }
        }
    }
}

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.JavaObject
QRFrameOptions

QRFrameOptions()

Initializes a new instance of the QRFrameOptions class.

Declaration

public QRFrameOptions()