Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用EPOSSDK打印UIImage_Objective C_Printing_Epson - Fatal编程技术网

Objective c 使用EPOSSDK打印UIImage

Objective c 使用EPOSSDK打印UIImage,objective-c,printing,epson,Objective C,Printing,Epson,我正在使用爱普生的ePOS SDK,它允许通过wifi连接到打印机(TM-T88V)。sdk()的链接 我正在使用以下代码从url加载UIImage NSData* data = [[NSData alloc] initWithContentsOfUrl:_url]; UIImage* image = [UIImage imageWithData:data]; 然后打印图像(使用ePOS)注意:我将跳过连接部分,因为它不包括在我的问题中。 EposBuilder* builder = [Epo

我正在使用爱普生的ePOS SDK,它允许通过wifi连接到打印机(TM-T88V)。sdk()的链接

我正在使用以下代码从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。有关示例,请参见下图

有没有关于如何正确打印的想法?我还发现了这个链接,它提供了一个关于缩放图像的链接,但它不起作用。有什么想法吗?多谢各位


我得到了解决方案,你不是已经解决了吗,我所做的是,通过
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];
}

我试过你的方法。但是图像的质量不是很好。此外,我还使用了UIViewContentModeScaleAspectToFill您能给我看一下您的收据照片并用resizedImageContentMode方法更新您的答案吗?有没有解决方案?我建议您根据纸张大小创建账单图像