是否可以配置Zebra标签,以便在到达标签的右边缘时停止打印?

时间:2014-12-04 00:58:50

标签: c# printing zebra-printers

我正在打印的标签的“描述”部分通常很短,如“超级”和“超人”,但一旦进入,他们就像“supercalifragilisticexpealidocious”一样长

在后一种情况下,文本环绕,但不“crlf”,因此打印原始行的部分。

crlif'ing也不会好,因为那会“甩掉”标签其余部分的对齐。

我想出了一个解决方法来截断描述,如果它太长了:

public void PrintLabel(string price, string description, string barcode)
{
    const int MAX_CAPS_DESC_LEN = 21;
    const int MAX_LOWERCASE_DESC_LEN = 32;
    try
    {
        // Users were getting wrapped descriptions causing legibility/alignment 
        //problems; this code could be elegantized, but at the cost of readability
        bool descAllUpper = HHSUtils.IsAllUpper(description);
        if (descAllUpper)
        {
            if (description.Length > MAX_CAPS_DESC_LEN)
            {
                description = description.Substring(0, MAX_CAPS_DESC_LEN);
            }
        }
        else // not all upper
        {
            if (description.Length > MAX_LOWERCASE_DESC_LEN)
            {
                description = description.Substring(0, MAX_LOWERCASE_DESC_LEN);
            }
        }
        . . .

...但有没有办法(属性/设置/配置/命令等)告诉打印机停在标签的边缘?

1 个答案:

答案 0 :(得分:1)

在Windows中&gt; <控制面板>打印机和设备,右键单击和打印机属性。您可以设置边距和内容。斑马打印机有很多设置。

此外,我们使用较小的字体来容纳字符,uline.com销售4x8标签我相信而不是使用标准4x6。

遗憾的是,截至2012年12月17日,当前Zebra Designer软件中没有Text Field Word Wrap选项。如果要实现这一点,还必须按照ZPL编程手册中的说明将ZPL代码添加到PRN文件中。

编辑:不得不缩进所有因为堆栈很奇怪。

来源Easyworks.com

包含和不包含Word Wrap的代码的样本PRN文件[以红色突出显示]

CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR2,2~SD8^JUS^LRN^CI0^XZ
^XA
^MMT
^PW448
^LL0488
^LS0
^BY1,3,34^FT84,244^BCN,,Y,N
^FD>:<%EXP%>0^FS
^BY1,3,34^FT84,175^BCN,,Y,N
^FD>:<%UID%>0^FS
^BY1,3,34^FT84,106^BCN,,Y,N
^FD>:<%PARTNO%>0^FS
^FT84,344^AAN,27,15^FH\^FD<%EXP%>^FS

^FB500,3,,,  //This is what the below is referencing

^FT84,293^AAN,18,10^FH\^FD<%WARN%>^FS
^PQ1,0,1,Y^XZ

没有自动换行的代码

CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR2,2~SD8^JUS^LRN^CI0^XZ
^XA
^MMT
^PW448
^LL0488
^LS0
^BY1,3,34^FT84,244^BCN,,Y,N
^FD>:<%EXP%>0^FS
^BY1,3,34^FT84,175^BCN,,Y,N
^FD>:<%UID%>0^FS
^BY1,3,34^FT84,106^BCN,,Y,N
^FD>:<%PARTNO%>0^FS
^FT84,344^AAN,27,15^FH\^FD<%EXP%>^FS
^FT84,293^AAN,18,10^FH\^FD<%WARN%>^FS
^PQ1,0,1,Y^XZ

ZPL编程手册摘录这里也是编程手册关于^ FB命令的摘录

^FB   - Field Block
Description The ^FB command allows you to print text into a defined block type format.
This command formats an ^FD or ^SN string into a block of text using the origin, font, and
rotation specified for the text string. The ^FB command also contains an automatic word-wrap function.

Format ^FBa,b,c,d,e
This table identifies the parameters for this format:
Parameters
a = width of text block line (in dots)
Accepted Values: 0 to the width of the label
Default Value: 0
If the value is less than font width or not specified, text does not print.

b = maximum number of lines in text block
Accepted Values: 1 to 9999
Default Value: 1
Text exceeding the maximum number of lines overwrites the last line. Changing the font size automatically increases or decreases the size of the block.

c = add or delete space between lines (in dots)
Accepted Values: -9999 to 9999
Default Value: 0
Numbers are considered to be positive unless preceded by a minus sign. Positive values add space; negative values delete space.

d = text justification Accepted Values:
L = left
C = center
R = right
J = justified
Default Value: L
If J is used the last line is left-justified.

e = hanging indent (in dots) of the second and remaining lines
Accepted Values: 0 to 9999
Default Value: 0

关于^ FB命令的注释此方案可用于促进特殊功能:

\& = carriage return/line feed   
\(*) = soft hyphen (word break with a dash)  
\\ = backslash (\)   
Item 1: ^CI13 must be selected to print a backslash (\).   
Item 2: If a soft hyphen escape sequence is placed near the end of a line, the hyphen is printed. If it is not placed near the end of the line, it is ignored.   
(*) = any alphanumeric character   

" If a word is too long to print on one line by itself (and no soft hyphen is specified), a hyphen is automatically placed in the word at the right edge of the block. The remainder of the word is on the next line. The position of the hyphen depends on word length, not a syllable boundary. Use a soft hyphen within a word to control where the hyphenation   
occurs.   
" Maximum data-string length is 3K, including control characters, carriage returns, and line feeds.   
" Normal carriage returns, line feeds, and word spaces at line breaks are discarded.   
" When using ^FT (Field Typeset), ^FTuses the baseline origin of the last possible line of text. Increasing the font size causes the text block to increase in size from bottom to top. This could cause a label to print past its top margin.   
" When using ^FO (Field Origin), increasing the font size causes the text block to increase in size from top to bottom.   
" ^FS terminates an ^FB command. Each block requires its own ^FB command.