public void Print(String text, String fontName, Int32 magnificationFactor, Int32 offsetX, Int32 offsetY, Int32 copies) { String labelScriptFile; ZPLGenerator ZPLGen; try { ZPLGen = new ZPLGenerator(); labelScriptFile = Environment.GetEnvironmentVariable("TEMP") + "\\Chi_ZPL.ZPL"; // Write the ZPL script to the temporary location on the local disc. ZPLGen.GenerateAlphaNumeric(labelScriptFile, text, fontName, magnificationFactor, offsetX, offsetY, copies); // Print file. Print(labelScriptFile); // Delete script file. File.Delete(labelScriptFile); } catch (Exception ex) { MessageBox.Show("Error when attempting to print label: " + ex.Message, Config.GetDialogTitleStandard(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void Print(BarCodeLabel[] barCodeLabels, Int32 fontHeight, Int32 fontWidth, Int32 offsetX, Int32 offsetY, BarCodeTextPositions textPosition) { String labelScriptFile; ZPLGenerator ZPLGen; try { ZPLGen = new ZPLGenerator(); labelScriptFile = Environment.GetEnvironmentVariable("TEMP") + "\\Chi_ZPL.ZPL"; // Check that all bar codes are valid. foreach (BarCodeLabel barCodeLabel in barCodeLabels) { if (!ZPLGen.ValidateBarCode128c(barCodeLabel.BarCode)) { MessageBox.Show("The bar code " + barCodeLabel.BarCode + " is not a valid Code128c bar code.", Config.GetDialogTitleStandard()); return; } } // Write the ZPL script to the temporary location on the local disc. ZPLGen.GenerateCode128c(labelScriptFile, barCodeLabels, fontHeight, fontWidth, offsetX, offsetY, textPosition); // Print file. Print(labelScriptFile); // Delete script file. File.Delete(labelScriptFile); } catch (Exception ex) { MessageBox.Show("Error when attempting to print bar codes: " + ex.Message, Config.GetDialogTitleStandard(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }