I am performing a text merge as well as inserting a barcode (aspose.barcode) into a document stream for printing. The output is going to a ZM400 thermal label printer. If I save my object as a document, then print, the document prints correctly onto a 3" x 2" label. If I simply pass my stream to the printer directly, the doc prints, but it prints counter clockwise, 90 degrees (I guess its portrait orientation).
I’m not sure if this is a words or barcode issue I need to address. Below is the code:
private void BuildLabel()
{
BarCodeBuilder bb = new BarCodeBuilder();
bb.CodeText = SerialNumber; bb.SymbologyType = Symbology.Code128;
bb.Code128CodeSet = Code128CodeSet.Auto;
bb.xDimension = .1f;
bb.BarHeight = 12f;
bb.CodeTextFont = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
System.IO.MemoryStream mStream = new System.IO.MemoryStream();
bb.BarCodeImage.Save(mStream, System.Drawing.Imaging.ImageFormat.Gif);
PrintLabel(bb);
}
private void PrintLabel(BarCodeBuilder barCode)
{
string path = @"C:\SomePath\CisLabels\";
Document doc = new Document(path + "CisLabel.docx");
doc.MailMerge.Execute(
new string[] { "PN", "QTY", "Description" },
new object[] { PartNumber, Qty, Description });
InsertBarcodeImage(doc, barCode);
// doc.Save("Merge.doc", SaveFormat.Doc, SaveType.OpenInWord,Response);
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = "ZDesigner ZM400 200 dpi (ZPL)";
// printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Label", 300, 200);
doc.Print(printerSettings);
}
private void InsertBarcodeImage(Document doc, BarCodeBuilder barCode)
{
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("Source");
builder.InsertImage(barCode.BarCodeImage);
}
Changing printer settings to to landscape had no effect. Specifying my paper dimension have no effect either. The template in use has its layout configured to 3" x 2". I’ve even bypassed the printer settings altogether and just called doc.Print(“Printer Name”) directly; same result. Attached is my template as well. I must be missing something.