示例#1
0
        private string GenerateBarCode128cSingle(string barCode, int height, int width, int offsetX, int offsetY, string text, LabelPrinter.BarCodeTextPositions textPos)
        {
            string ret;
            int    textHeight, textWidth;

            string fontName;
            int    magFactor, spacing;
            int    textFieldBlockWidthPoints, textFieldMaxLines;
            int    textFieldLineSpacePoints, textFieldCharactersPerLine;

            try
            {
                fontName  = Settings.Default.PlateLabelFontName;
                magFactor = Settings.Default.PlateLabelFontMagnFactor;
                spacing   = Settings.Default.PlateLabelBarCodeYSpacingPoints;
                textFieldBlockWidthPoints  = Settings.Default.PlateLabelTextBlockWidthPoints;
                textFieldMaxLines          = Settings.Default.PlateLabelTextMaxLines;
                textFieldLineSpacePoints   = Settings.Default.PlateLabelTextLineSpacePoints;
                textFieldCharactersPerLine = Settings.Default.PlateLabelTextCharsPerLine;

                textHeight = magFactor * this.GetFontBaseHeight(fontName);
                textWidth  = magFactor * this.GetFontBaseWidth(fontName);

                ret = "";
                ret = ret + "^XA";
                ret = ret + "^LH" + offsetX.ToString() + "," + offsetY.ToString();

                //If the text should be above the bar code, print the text first.
                if (textPos == LabelPrinter.BarCodeTextPositions.Above)
                {
                    ret = ret + "^A" + fontName + textHeight.ToString() + "," + textWidth.ToString();
                    ret = ret + "^FO" + "0,0";
                    ret = ret + "^FD" + text + "^FS";
                }

                //Print the actual bar code.
                ret = ret + "^FO" + "0," + Convert.ToString(textHeight + spacing);
                ret = ret + "^BY" + width.ToString();
                ret = ret + "^BCN," + Convert.ToString(height) + ",N,N,N";
                ret = ret + "^FD>;" + barCode + "^FS";

                //If the text should be on the right-hand side of the bar code, print the text now.
                if (textPos == LabelPrinter.BarCodeTextPositions.Right)
                {
                    if (width <= 4)
                    {
                        ret = ret + "^FO" + Convert.ToString(barCode.Length * width * 7 + 120) + "," + Convert.ToString(textHeight + spacing);
                    }
                    else
                    {
                        ret = ret + "^FO" + Convert.ToString(barCode.Length * width * 7 + 200) + "," + Convert.ToString(textHeight + spacing);
                    }
                    ret = ret + "^A" + fontName + textHeight.ToString() + "," + textWidth.ToString();
                    ret = ret + "^FB" + textFieldBlockWidthPoints.ToString() + "," + textFieldMaxLines.ToString() + "," + textFieldLineSpacePoints.ToString() + ",";
                    ret = ret + "^FD" + FormatText(text, "\\&", textFieldCharactersPerLine) + "^FS";
                }

                ret = ret + "^XZ";

                return(ret);
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
示例#2
0
        public Boolean GenerateCode128c(String targetFileName, LabelPrinter.BarCodeLabel[] barCodeLabelArray, int height, int width, int offsetX, int offsetY, LabelPrinter.BarCodeTextPositions textPos)
        {
            int    i;
            string script;

            ChiasmaDep.IO.FileServer fs;

            script = "";

            for (i = 0; i <= barCodeLabelArray.GetUpperBound(0); i++)
            {
                script = script + this.GenerateBarCode128cSingle(barCodeLabelArray[i].BarCode, height, width, offsetX, offsetY, barCodeLabelArray[i].Text, textPos);
            }

            fs = new ChiasmaDep.IO.FileServer();
            return(fs.SaveString(script, targetFileName));
        }