Add Aztec Barcodes

Navigation:  How to Use It in Reporting Services >

Add Aztec Barcodes

Previous pageReturn to chapter overviewNext page

Follow the instructions to add the Aztec barcodes to the report.

 

1.In order to use the Aztec .NET control in the Reporting Services, please copy MW6.Aztec.dll to "C:\Program Files\Microsoft Visual Studio X\Common7\IDE\PrivateAssemblies" for 32 bit OS or "C:\Program Files (x86)\Microsoft Visual Studio X\Common7\IDE\PrivateAssemblies" for 64 bit OS, the X value is associated with Visual Studio .NET version, it might be 8 for .NET 2005, 9.0 for .NET 2008, 10.0 for .NET 2010, 11.0 for .NET 2012.

 

2.Right click the last column in the table, Select the "Insert Column to the Right".

Insert_Column

3.Change the column title to the "Aztec Barcode".

Aztec_Column_Title

4.On the "Report" menu, click the "Report Properties", click the "References" tab, click the two-dot button Three_Dots to open the "Add Reference" dialog.

A. Click the "Browse" tab, navigate to the location of the assembly MW6.Aztec.dll, select the file and click the "Add" button.

B. Click the ".NET" tab, highlight the assemblies "System.Drawing" and "System.Windows.Form", click the "Add" button.

C. Enter "MW6.Aztec.AztecNet" in the "Class name" box, enter "objAztec" in the "Instance name" box to create an assembly object to use in the code to retrieve the Aztec barcode image byte stream.

Aztec_Report_Ref

5.On the same "Report Properties" dialog, click the "Code" tab, copy and paste the following code into this tab, this function is used to retrieve the Aztec barcode image byte stream, modify the code a bit to meet your application requirements.

 

Public Function GetImgStream(ByVal DataStr As String) As Byte()

 

 Dim ActualWidth As Integer, ActualHeight As Integer

 Dim ExtraWidth As Integer, ExtraHeight As Integer

 

 ' Message

 objAztec.Data = DataStr

 

 ' Module Size

 objAztec.ModuleSize = 0.07

 

 ' Error Correction Level

 objAztec.CorrectionLevel = 23

 

 ' Mode

 objAztec.Mode = 0

 

 ' Preferred Format

 objAztec.PreferredFormat = 0

 

 ' Orientation

 objAztec.Orientation = 0

 

 ' Handle Tilde Character?

 objAztec.HandleTilde = True

 

 ExtraWidth = 60

 ExtraHeight = 80

 

 objAztec.GetActualSize(True, Nothing, ActualWidth, ActualHeight)

 

 objAztec.SetSize(ActualWidth + ExtraWidth, ActualHeight + ExtraHeight)

 

 Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream

 Dim ImgStream As Byte()

 

 objAztec.SaveAsMemory(MS, System.Drawing.Imaging.ImageFormat.Jpeg)

 

 ImgStream = MS.ToArray

 

           MS.Close()

 

 Return ImgStream

 

End Function


 

Aztec_Report_Code

6.Change the "BackgroundImage" property of the text box in the "Aztec Barcode" column to display the Aztec barcode image encoding ID value.

A. Source: Select the Database from the drop-down list, since the data will be pulled from a database field.

B. Value: Enter the string "=code.GetImgStream(Fields!ID.Value)", it will ask the report to use the GetImgStream() function to retrieve the Aztec barcode image byte stream for the ID field value of the database.

C. MIMEType: Select the image/jpeg from the drop-down list, since the Aztec barcode image is in jpeg format.

D. BackgroundRepeat: Select the NoRepeat from the drop-down list, so only one image will be placed in the text box.

Prop_1D_Text

7.Click the "Preview" tab to check the Aztec barcode result.

Aztec_Report_Preview

8.For the reporting services deployment, check out Microsoft Knowledge Base article 842419 with the title "How to grant permissions to a custom assembly that is referenced in a report in Reporting Services", it is required to update the security settings of the .NET Framework to allow the MW6.Aztec.dll assembly to run properly.