Created
December 26, 2023 11:51
-
-
Save conholdate-gists/39b684ca4637f0b4ef3a94b2f2b1df1a to your computer and use it in GitHub Desktop.
Add Barcode to Word DOCX in C# | Create and Insert QR Code in DOCX DOC Document using .NET
This file contains 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
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode | |
Aspose.BarCode.Generation.BarcodeGenerator generator = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.Code39Standard, "1234567890"); | |
// Creating memory stream and save barcode image to memory stream | |
Stream ms = new MemoryStream(); | |
generator.Save(ms, Aspose.BarCode.Generation.BarCodeImageFormat.Bmp); | |
// Create a new Word document | |
Aspose.Words.Document doc = new Aspose.Words.Document(); | |
// Create builder for document object | |
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); | |
// Insert the barCode image into the document | |
builder.InsertImage(ms); | |
// Save the word document | |
doc.Save("Barcode.docx"); |
This file contains 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
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode | |
Aspose.BarCode.Generation.BarcodeGenerator generator = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.QR, "1234567"); | |
// Creating memory stream and save barcode image to memory stream | |
Stream ms = new MemoryStream(); | |
generator.Save(ms, Aspose.BarCode.Generation.BarCodeImageFormat.Bmp); | |
// Create a new Word document | |
Aspose.Words.Document doc = new Aspose.Words.Document(); | |
// Create builder for document object | |
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); | |
// Insert the barCode image into the document | |
builder.InsertImage(ms, | |
Aspose.Words.Drawing.RelativeHorizontalPosition.Margin, | |
400, | |
Aspose.Words.Drawing.RelativeVerticalPosition.Margin, | |
-50, | |
100, | |
100, | |
Aspose.Words.Drawing.WrapType.Square); | |
// Save the word document | |
doc.Save("QR-Code.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment