ByteScout QR Code SDK - C# - vCard QR Code - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout QR Code SDK – C# – vCard QR Code

  • Home
  • /
  • Articles
  • /
  • ByteScout QR Code SDK – C# – vCard QR Code

ByteScout QR Code SDK – C# – vCard QR Code

Program.cs

using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using Bytescout.BarCode;
using Thought.vCards;

namespace GenerateVCardQRCode
{
	/// <summary>
	/// This example demonstrates generation of QR Code encoded vCard.
	/// It uses vCard library by David Pinch:
	/// 
	/// vCard Class Library for .NET (Version 0.4; LGPL license)
	/// Copyright (c) 2007-2009 David Pinch 
	/// http://www.thoughtproject.com/Libraries/vCard/
	/// 
	/// </summary>
	class Program
	{
		static void Main(string[] args)
		{
			// Generate vCard
			vCard vCard = new vCard();
			vCard.GivenName = "Forrest";
			vCard.FamilyName = "Gump";
			vCard.Organization = "Bubba Gump Shrimp Co.";
			vCard.Title = "Shrimp Man";
			vCard.Phones.Add(new vCardPhone("(111) 555-1212", vCardPhoneTypes.Home));
			vCard.EmailAddresses.Add(new vCardEmailAddress("forrestgump@example.com", vCardEmailAddressType.Internet));
			
			vCardDeliveryAddress address = new vCardDeliveryAddress();
			address.AddressType.Add(vCardDeliveryAddressTypes.Home);
			address.Street = "100 Waters Edge";
			address.City = "Baytown";
			address.Region = "LA";
			address.PostalCode = "30314";
			address.Country = "United States of America";
			vCard.DeliveryAddresses.Add(address);

			// Save vCard data to string
			vCardStandardWriter writer = new vCardStandardWriter();
			StringWriter stringWriter = new StringWriter();
			writer.Write(vCard, stringWriter);

			// Create and activate Bytescout.Barcode.QRCode instance
			using (QRCode barcode = new QRCode("demo", "demo"))
			{
				// Set barcode value
				barcode.Value = stringWriter.ToString();
				// Save barcode to image
				barcode.SaveImage("result.png", ImageFormat.Png);
			}

		    // Open generated barcode image in default associated application 
		    Process.Start("result.png");
        }
	}
}


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next