LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Use the Annotations SDK with the Barcode SDK to write movable and editable barcodes
#1
Posted
:
Monday, April 17, 2017 8:30:27 AM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
I have written a small sample demo that shows how to use our Automated annotations along with our
BarcodeEngine and
BarcodeWriter classes to write barcodes to a
AnnStampObject.
Here is a screenshot of what the demo looks like:
Here is the relevant code from the sample:
Code to write the barcode to an image:Code:RasterImage barcodeImage = RasterImage.Create(300, 300, 24, 150, RasterColor.White);
LogicalRectangle writebounds = LogicalRectangle.FromLTRB(0, 0, barcodeImage.ImageSize.Width, barcodeImage.ImageSize.Height, LogicalUnit.Pixel);
BarcodeEngine barcodeEngine = new BarcodeEngine();
QRBarcodeData qrData = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR) as QRBarcodeData;
qrData.Value = barcodestring;
QRBarcodeWriteOptions options = new QRBarcodeWriteOptions();
options.HorizontalAlignment = BarcodeAlignment.Center;
options.VerticalAlignment = BarcodeAlignment.Center;
barcodeEngine.Writer.CalculateBarcodeDataBounds(writebounds, barcodeImage.XResolution, barcodeImage.YResolution, qrData, options);
barcodeEngine.Writer.WriteBarcode(barcodeImage, qrData, options);
Code to add the Barcode Image to the stamp and the stamp to the Automation programmatically:Code:AnnStampObject stamp = new AnnStampObject();
stamp.Rect = LeadRectD.Create(200, 200, 600, 600);
stamp.Text = "";
stamp.Stroke.Stroke = AnnSolidColorBrush.Create("");
using (MemoryStream ms = new MemoryStream())
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Save(barcodeImage, ms, RasterImageFormat.Png, 32);
stamp.Picture = new AnnPicture(ms.ToArray());
}
annAutomation.Container.Children.Add(stamp);
annAutomation.InvalidateObject(stamp);
You can download the project here:
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Use the Annotations SDK with the Barcode SDK to write movable and editable barcodes
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.