Class QrCode
Represents a QR Code that can be rendered.
Inheritance
Namespace: IronQr
Assembly: IronQr.dll
Syntax
public class QrCode : Object
QrCode is the generated symbol a QrWriter returns, ready to save, stamp, or embed. It represents one rendered QR code, and its methods turn that code into the output a project needs without going back to the writer.
Save writes the code to an image and accepts an optional QrStyleOptions to set size, color, margins, and a logo, returning an AnyBitmap. ToDataUrl and ToHtmlTag produce web-ready output for embedding directly in a page. StampToExistingPdfPage and StampToExistingPdfPages place the code onto a PDF at a given position and page, useful for adding a code to an invoice or ticket. Verify decodes the rendered code and confirms it matches an expected value, a quick self-check after generation. Each method works from the same rendered symbol, so one QrWriter.Write result can be saved, stamped onto a PDF, and exported to HTML without regenerating it.
QrWriter.Write("https://ironsoftware.com").Save("qr.png");The generate QR code example saves a code to an image, and the stamp to PDF how-to places one on a document.
Methods
Save(Nullable<QrStyleOptions>)
Returns the QR Code as an AnyBitmap object. Optionally include styling such as size, color, logo, and other customization by providing the QrStyleOptions parameter.
To Save this QR Bitmap to a File use the
SaveAs method on IronSoftware.Drawing.AnyBitmap:
AnyBitmap qr = myQr.Save();
qr.SaveAs("qr.png");
Declaration
public AnyBitmap Save(Nullable<QrStyleOptions> styleOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<QrStyleOptions> | styleOptions |
Returns
| Type | Description |
|---|---|
| IronSoftware.Drawing.AnyBitmap |
StampToExistingPdfPage(String, Int32, Int32, Int32, String)
Stamps (draws) the QR Code onto an existing page of an existing PDF document.
Declaration
public void StampToExistingPdfPage(string filePath, int x, int y, int pageNumber, string password = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path of the PDF which will have the QR Code added to it.. |
| System.Int32 | x | The horizontal position of the QR Code on the PDF page in pixels |
| System.Int32 | y | The vertical position of the QR Code on the PDF page in pixels |
| System.Int32 | pageNumber | The page of the PDF to stamp. [One Based] such that the first page is number 1 rather than 0. |
| System.String | password | The PDF encryption or administrator password if this PDF is digitally protected from modification or opening. |
StampToExistingPdfPages(String, Int32, Int32, IEnumerable<Int32>, String)
Stamps (draws) the QR Code onto multiple existing pages of an existing PDF document.
Declaration
public void StampToExistingPdfPages(string filePath, int x, int y, IEnumerable<int> pageNumbers, string password = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path of the PDF which will have the QR Code added to it.. |
| System.Int32 | x | The horizontal position of the QR Code on each PDF page in pixels |
| System.Int32 | y | The vertical position of the QR Code on each PDF page in pixels |
| System.Collections.Generic.IEnumerable<System.Int32> | pageNumbers | The page numbers of the PDF to stamp as an enumeration, list or array. [One Based] such that the first page is number 1 rather than 0. |
| System.String | password | The PDF encryption or administrator password if this PDF is digitally protected from modification or opening. |
ToDataUrl()
Converts the QR Code to a base64 data URL.
The data URI scheme is a uniform resource identifier (URI) scheme that provides a way to include data in-line in web pages as if they were external resources.
Declaration
public string ToDataUrl()
Returns
| Type | Description |
|---|---|
| System.String | The Data URL as a string. |
See Also
ToHtmlTag()
Renders the QR Code as a HTML image Tag. The tag is fully formed (using a data-url> and can be injected into HTML with no JS, CSS or image dependencies.
Declaration
public string ToHtmlTag()
Returns
| Type | Description |
|---|---|
| System.String | An Html img tag as a string. |
Verify(String)
Verifies this QR Code is still readable by IronQR.
Resizing a QR Code to a very small size or using unconventional colors may make it unreadable to a machine. This method verifies that a QR Code is still fully readable.
Declaration
public bool Verify(string expected = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | expected |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|