使用 ePOS SDK 打印 UIImage [英] Printing UIImage using ePOS SDK

查看:77
本文介绍了使用 ePOS SDK 打印 UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using ePOS SDK from Epson which allows connecting to the printer (TM-T88V) via wifi. link for the sdk (http://pos.epson.com/mobilesdks/index.htm)

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

I'm loading an UIImage from a url using this code.

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

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

Then to Print the image (using ePOS) NOTE: I will skip the connecting part since it is not included to my question.

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.见下图示例

关于如何使其正确打印的任何想法?我还发现这个 使用 AirPrint 打印 UIImage 会导致内容被截断 提供了缩放图像的链接,但它不起作用.有任何想法吗?谢谢.

Any ideas on how to make it print properly? Also i've found this Printing UIImage using AirPrint causes cut-off content which gave a link on scaling the image but it doesn't work. Any ideas? Thank you.

推荐答案

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

I got the solution, don't mine of you already resolved it, The thing i did was, to save the Image in Documents folder through NSFileManager and get the same from the documents folder and add a space to the image before adding, sorry for my english.. you need to implement your own code to save & retrive image through file manager.

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];
}

这篇关于使用 ePOS SDK 打印 UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆