Last active
April 2, 2025 22:44
-
-
Save larsschenk/e8a640fe577c6b79678b3b89d27adeff to your computer and use it in GitHub Desktop.
Visual C# examples using the ActiveBarcode REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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/v2/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