选项卡TextBox和打印输出之间的差异

时间:2016-07-05 19:34:42

标签: vb.net printing

我正在建立一个订单打印应用程序,我最初遇到了一个问题,我自己解决了。我需要在checkListArrayList中设置标签位置,以便无论商品名称有多长,价格都会排成一行。我已经遗漏了下面的声明,因为它们与我的问题无关,但我这样做是使用:

Process: com.example.siddhi.meavita, PID: 20503
    java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5
    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
    at java.util.ArrayList.get(ArrayList.java:308)
    at com.example.siddhi.meavita.Activities.CheckListActivity$GetCheckListsItemAsyncTask.onPostExecute(CheckListActivity.java:336)
    at com.example.siddhi.meavita.Activities.CheckListActivity$GetCheckListsItemAsyncTask.onPostExecute(CheckListActivity.java:261)

适用于//Filter image I with filter kernel: // 1/9 1/9 1/9 // 1/9 1/9 1/9 // 1/9 1/9 1/9 //I - Input image in pixel ordered BGR format //image_width - Number of columns of I //image_height - Number of rows of I //J - Destination "smoothed" image in BGR format. //I and J is pixel ordered BGR color format (size in bytes is image_width*image_height*3): //BRGBRGBRGBRGBR //BRGBRGBRGBRGBR //BRGBRGBRGBRGBR //BRGBRGBRGBRGBR // //Limitations: //I and J must be two separate arrays (in place computation is not supported). void BgrSmoothing(const unsigned char I[], int image_width, int image_height, unsigned char J[]) { const int scale = (int)((1.0/9.0)*(1 << 15) + 0.5); //1/9 expanded by 2^15 (add 0.5 for rounding). const int rounding_ofs = (1 << 14); //0.5 expanded by 2^14 int x, y; const unsigned char *I0; //Points beginning of row y-1 (in source image I). const unsigned char *I1; //Points beginning of row y (in source image I). const unsigned char *I2; //Points beginning of row y+1 (in source image I). int x0, x1, x2; //x0 - pixel to the left of x1, x1 - center, x2 - pixel to the right of x1 unsigned char *J1; //Points beginning of row y (in destination image J). //3x3 source blue pixels, 3x3 source green pixels, 3x3 source red pixels. unsigned char b00, b01, b02, g00, g01, g02, r00, r01, r02; unsigned char b10, b11, b12, g10, g11, g12, r10, r11, r12; unsigned char b20, b21, b22, g20, g21, g22, r20, r21, r22; unsigned char b, g, r; //Destination blue, green and red pixels. for (y = 0; y < image_height; y++) { if (y == 0) I0 = I; //Handle first row: use row 0 instead of row -1 (row -1 exceeds image bounds). else I0 = &I[(y-1)*image_width*3]; //Pointer to beginning of source row above row y in image I. I1 = &I[y*image_width*3]; //Pointer to beginning of source row y in image I. if (y == image_height-1) I2 = &I[y*image_width*3]; //Handle last row: use row image_height-1 instead of row image_height (row image_height exceeds image bounds). else I2 = &I[(y+1)*image_width*3]; //Pointer to beginning of source row below row y in image I. J1 = &J[y*image_width*3]; //Pointer to beginning of destination row in image J. //Handle first pixel: for (x = 0; x < image_width; x++) { //Multiply x by 3, to convert pixel index to byte index (in BGR forst each pixel is 3 bytes). x0 = (x == 0) ? (0) : (x-1)*3; //Handle x0 coordinate of first pixel in the row. x1 = x*3; x2 = (x == image_width-1) ? (image_width-1)*3 : (x+1)*3; //Handle x2 coordinate of last pixel in the row. //Load 3x3 blue pixels: b00 = I0[x0]; b01 = I0[x1], b02 = I0[x2]; b10 = I1[x0]; b11 = I1[x1], b12 = I1[x2]; b20 = I2[x0]; b21 = I2[x1], b22 = I2[x2]; //Load 3x3 green pixels: g00 = I0[x0+1]; g01 = I0[x1+1], g02 = I0[x2+1]; g10 = I1[x0+1]; g11 = I1[x1+1], g12 = I1[x2+1]; g20 = I2[x0+1]; g21 = I2[x1+1], g22 = I2[x2+1]; //Load 3x3 red pixels: r00 = I0[x0+2]; r01 = I0[x1+2], r02 = I0[x2+2]; r10 = I1[x0+2]; r11 = I1[x1+2], r12 = I1[x2+2]; r20 = I2[x0+2]; r21 = I2[x1+2], r22 = I2[x2+2]; //Sum all 9 blue elements, all 9 green elements and all 9 red elements (convert to int to avoid overflow). int sum_b = (int)b00+(int)b01+(int)b02+(int)b10+(int)b11+(int)b12+(int)b20+(int)b21+(int)b22; int sum_g = (int)g00+(int)g01+(int)g02+(int)g10+(int)g11+(int)g12+(int)g20+(int)g21+(int)g22; int sum_r = (int)r00+(int)r01+(int)r02+(int)r10+(int)r11+(int)r12+(int)r20+(int)r21+(int)r22; //b = round(sum_b*(1/9)). //Because b i positive round(b) = floor(b+0.5). //Use following computation instead: b = floor((sum_b*(1.0/9.0)*2^15 + 2^14) / 2^15) b = (unsigned char)((sum_b*scale + rounding_ofs) >> 15); //Destination blue pixel. g = (unsigned char)((sum_g*scale + rounding_ofs) >> 15); //Destination green pixel. r = (unsigned char)((sum_r*scale + rounding_ofs) >> 15); //Destination red pixel. //Store b,g,r elements to destination row J1. J1[x1] = b; J1[x1+1] = g; J1[x1+2] = r; } } } ,但当我连接到我的Epson收据打印机并发送TextBox的内容时,它会将我的标签解释为正常大小的标签 - 而不是6和85的两个标签我在打印机上获得了默认定位标签,这些标签会破坏输出。

任何人都知道我如何在打印机上设置标签位置(或者可能还有其他方式?),以便打印机输出与文本框中的标签相匹配?

1 个答案:

答案 0 :(得分:0)

您需要在文本框中设置制表位,并且制表符在您的打印机中停止使用相同的字符数或距离(取决于您是否使用比例或固定字体)。

这里的命令参考应该(大部分)与您的打印机一起使用。收据打印机确实有一些附加功能,如刀杆和可下载的图像,但它应该足够接近。 https://files.support.epson.com/pdf/general/escp2ref.pdf您还可以谷歌查找特定打印机的技术手册,该手册应该包含任何特定代码。

最大的问题是您需要自己生成整个文档并将其作为RAW格式的文档发送到打印机或打印队列,包含所有初始化序列和控制代码,并将其发送到打印机使用RawPrinterHelper(https://support.microsoft.com/en-us/kb/322090)。

它很混乱,但我知道在点阵或热敏收据打印机上获得精确定位,快速输出和良好文本质量的唯一方法。

可能能够将制表位设置到所需位置,然后在打印机支持时保存配置。问题是,如果使用标准的Epson驱动程序进行打印,打印机将重新初始化并将所有内容呈现为位图,而不是使用打印机字体和您想要的设置进行打印。

你也可以试试&#34; Generic&#34;打印机驱动程序,其中包含可以配置打印机初始化代码的插槽,但您仍需要包含字体更改/粗体等所需的任何转义序列。在你的文件中。