Skip to content

Instantly share code, notes, and snippets.

@larsschenk
Last active December 31, 2019 15:58
Show Gist options
  • Save larsschenk/e8a640fe577c6b79678b3b89d27adeff to your computer and use it in GitHub Desktop.
Save larsschenk/e8a640fe577c6b79678b3b89d27adeff to your computer and use it in GitHub Desktop.
Visual C# examples using the ActiveBarcode REST API
// On a form are an input field (Textbox1),
// a Picturebox (Picturebox1) and a button (Button1).
//
// If you click the button, a barcode with the text of the input field
// is called up via barcode API and drawn into the picturebox.
//
private void button1_Click(object sender, EventArgs e)
{
string ReqUrl = "https://api.activebarcode.net/v1/png?access=YOUR-KEY-HERE&";
var ReqParam = "code =CODE128&width=" + System.Convert.ToString(pictureBox1.Width)
+ "&height=" + System.Convert.ToString(pictureBox1.Height)
+ "&text=" + textBox1.Text;
System.Net.WebRequest req = System.Net.WebRequest.Create(ReqUrl + ReqParam);
using (System.Net.WebResponse request = req.GetResponse())
{
using (System.IO.Stream stream = request.GetResponseStream())
{
pictureBox1.Image = new Bitmap(System.Drawing.Image.FromStream(stream));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment