【问题标题】:Printing UIImage using ePOS SDK使用 ePOS SDK 打印 UIImage
【发布时间】:2012-07-19 15:37:54
【问题描述】:

我正在使用 Epson 的 ePOS SDK,它允许通过 wifi 连接到打印机 (TM-T88V)。 sdk 的链接 (http://pos.epson.com/mobilesdks/index.htm)

我正在使用此代码从 url 加载 UIImage。

NSData* data = [[NSData alloc] initWithContentsOfUrl:_url];
UIImage* image = [UIImage imageWithData:data];

然后打印图像(使用 ePOS)注意:我将跳过连接部分,因为它不包含在我的问题中。

EposBuilder* builder = [EposBuilder alloc]  initWithPrinterModel:@"TM-T88V" lang:EPOS_OC_MODEL_ANK];

EposPrint* printer = [[EposPrint alloc] init];

int retVal = EPOS_OC_SUCCESS;
unsigned long status = 0;

retVal = [builder addImage:image X:0 Y:0 Width:image.size.width Height:image.size.Height Color: EPOS_OC_COLOR_1];

retVal = [printer sendData:builder Timeout:10000 Status:&status];

现在我的问题是打印结果要小很多,请看图像的大小是 271x368px。示例见下图

关于如何使其正确打印的任何想法?我还发现了这个Printing UIImage using AirPrint causes cut-off content,它提供了一个关于缩放图像的链接,但它不起作用。有任何想法吗?谢谢。

【问题讨论】:

  • 有人有解决办法吗?
  • 我建议您根据纸张大小创建账单图像

标签: objective-c printing epson


【解决方案1】:

我得到了解决方案,你不是我的已经解决了,我做的是通过NSFileManager将图像保存在文档文件夹中,并从文档文件夹中获取相同的内容并为图像添加一个空格在添加之前,对不起我的英语......你需要实现自己的代码来通过文件管理器保存和检索图像。

NSData *dataFromUrl=[[NSData alloc] initWithContentsOfURL:url];
    UIImage *image1 = [UIImage imageWithData:dataFromUrl];
    if(image1)
    {
        [Filemanager saveReceiptLogoImage:image1];
    }

//IN打印机类,

    UIImage *image1 = [Filemanager receiptLogo];
                if(image1)
                {
  result = [builder addText:@"    "];
   UIImage *resizedImage = [image1 resizedImageWithContentMode:UIViewContentModeScaleAspectFit bounds:CGSizeMake(512, 350) interpolationQuality:kCGInterpolationHigh];
                    result = [builder addImage:resizedImage X:0 Y:0 Width:MIN(512, resizedImage.size.width) Height:resizedImage.size.height Color:EPOS_OC_COLOR_1];
}

【讨论】:

  • 试过你的方法。但是图像质量不是很好。还使用了 UIViewContentModeScaleAspectToFill
  • 你能给我看你的收据照片并用 resizedImageContentMode 方法更新你的答案吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-09
  • 2015-04-04
  • 2016-07-07
  • 2014-05-11
  • 1970-01-01
  • 2015-08-29
  • 2020-11-15
相关资源
最近更新 更多