And for any of those interested, here is the code for the DLL that I had loaded into SSRS to generate the PDF417 barcodes on-demand. When the Job Traveler was printed from Epicor, the RDL would load the namespace of the DLL from SSRS which would make the functions from that class available to SSRS.
NOTE: Keep in mind that the Namespaces, class names, method names, etc., have changed as I was developing this, and learning new things as I went. So what is shown here may not always match with other code snippets shown here. However, it should be clear enough what is going on so that anyone wanting to try something similar can use this as a reference, and not treat it as gospel. When/if I ever find the final stuff, I will update these posts accordingly.
Anyways, on with the codeā¦In the report itself, I created an Image field, and added an expression to it, like this:
=SSRS_Barcodes.SSRS_Barcode_Generator.Generate_Barcode("PDF417", "$" + Fields!JobNum.Value + "|" + Fields!OprSeq.Value + "|" + Fields!RunQty.Value + "|" + Fields!JobOper_DueDate.Value + "#")
That turns this box in the Report Builder
into this:
The code below is for the DLL that gets loaded into SSRS and basically returns a BMP images as an array of bytes that gets displayed in the final report output.
Expand for full code
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using SSRS_Barcodes.My.Resources;
using ZXing;
using ZXing.Common;
using ZXing.QrCode.Internal;
using ZXing.Rendering;
namespace SSRS_Barcodes
{
public class SSRS_Barcode_Generator
{
public enum BarcodeType
{
AZTEC = 0,
DATA_MATRIX = 1,
QR_CODE = 2,
PDF417 = 3
}
public static byte[] Generate_Barcode(int bcType, string str, int x = 0, int y = 0, int m = 0)
{
byte[] bc = null;
if (bcType == 0)
{
bc = SSRS_Barcode_Generator.Generate_Barcode_AZTEC(str);
}
else if (bcType == 1)
{
bc = SSRS_Barcode_Generator.Generate_Barcode_DATA_MATRIX(str);
}
else if (bcType == 2)
{
bc = SSRS_Barcode_Generator.Generate_Barcode_QR_CODE(str, x, y, m);
}
else if (bcType == 3)
{
bc = SSRS_Barcode_Generator.Generate_Barcode_PDF417(str);
}
return bc;
}
public static byte[] Generate_Barcode_PDF417(string str)
{
Image image = new BarcodeWriter
{
Format = BarcodeFormat.PDF_417
}.Write(str);
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Bmp);
return ms.GetBuffer();
}
public static byte[] Generate_Barcode_AZTEC(string str)
{
Image image = new BarcodeWriter
{
Format = BarcodeFormat.AZTEC
}.Write(str);
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Bmp);
return ms.GetBuffer();
}
public static byte[] Generate_Barcode_DATA_MATRIX(string str)
{
Image image = new BarcodeWriter
{
Format = BarcodeFormat.DATA_MATRIX
}.Write(str);
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Bmp);
return ms.GetBuffer();
}
public static byte[] Generate_Barcode_QR_CODE(string str, int x, int y, int m)
{
BarcodeWriter barcodeWriter = new BarcodeWriter();
EncodingOptions encOptions = new EncodingOptions
{
PureBarcode = false,
Width = x,
Height = y,
Margin = m
};
encOptions.Hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
barcodeWriter.Renderer = new BitmapRenderer();
barcodeWriter.Options = encOptions;
barcodeWriter.Format = BarcodeFormat.QR_CODE;
Bitmap bitmap = barcodeWriter.Write(str);
Bitmap overlay = new Bitmap(Resources.BlackFlag);
checked
{
int deltaHeight = bitmap.Height - overlay.Height;
int deltaWidth = bitmap.Width - overlay.Width;
Graphics.FromImage(bitmap).DrawImage(overlay, new Point((int)Math.Round((double)deltaWidth / 2.0), (int)Math.Round((double)deltaHeight / 2.0)));
MemoryStream ms = new MemoryStream();
bitmap.Save(ms, ImageFormat.Bmp);
return ms.GetBuffer();
}
}
}
}
You can also generate other barcode types such as QR Codes or AZTEC codes using that library if the situation calls for it. You just need to change the data you are passing to the methods in the SSRS Imagebox (some require the width and height, .
That is everything I am able to find right now. Hopefully it is enough to help point someone in the right direction with how to start an endeavor such as this.