2012-07-20 65 views
0

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

我正在使用此代码从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它给了一个缩放图像的链接,但它不起作用。有任何想法吗?谢谢。

enter image description here

+0

任何人对此有一个解决方案吗? – Iya 2016-03-04 07:50:16

+0

我建议你根据纸张尺寸 – 2017-12-22 11:15:38

回答

0

我得到了解决,不要的你我已经解决了,我做的事情是,在其中保存文件的影像通过NSFileManager文件夹,从文件夹得到相同的,并添加在添加图片之前的空间,对不起我的英语..你需要实现自己的代码,以通过文件管理器保存&回放图像。

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

//打印机类,

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

尝试你的方法创建你的账单图像。但是图像质量并不好。还可以使用UIViewContentModeScaleAspectToFill – jongbanaag 2013-05-20 12:46:20

+0

您可以向我显示您的收据照片并使用resizedImageContentMode方法更新您的答案 – 2018-01-27 10:25:09