QR-Code Contact Information |
This sample generates a contact information QR-Code barcode and saves it to an image file.
using Opait.Barcode; using Opait.Barcode.QRCode; // This sample creates a QR-Code encoded contact information barcode. Only few fields are used here. // Many more fields, including addresses and multiple phone numbers, can be added. static void CreateContactInfo(string fileName, string firstName, string lastName, string company, string email, string cellNumber) { // Create a contact info payload with specified fields. var contact = new ContactInfo(ContactFormat.VCard, firstName, lastName) { Organization = company, Email = email, MobilePhone = cellNumber }; // Create a QR-Code and pass formatted text from contact info. var barcode = Barcode.Create(BarcodeType.QRCode, contact.ToString()); // Create a bitmap renderer with default parameters. var renderer = new BarcodeBitmapRenderer(); // Render to a barcode bitmap of 400x400 pixels. using (var bitmap = renderer.RenderBarcode(barcode, 400, 400)) { // Save the rendered image. bitmap.Save(fileName); } }