Printing UIImage using the ePOS SDK

I use Epson's ePOS SDK, which allows you to connect to the printer (TM-T88V) via Wi-Fi. sdk link ( http://pos.epson.com/mobilesdks/index.htm )

I am loading UIImage from a url using this code.

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

Then to print the image (using ePOS) NOTE: I will skip the connecting part as it is not included in 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]; 

Now my problem is that the printed result is much smaller, see image size 271x368px. see image below for sample

Any ideas on how to print it correctly? I also found that Printing UIImage using AirPrint causes disabled content that gave a link to image scaling, but it does not work. Any ideas? Thanks.

enter image description here

0
source share
1 answer

I got a solution, not because you already resolved it. I did this to save the Image in Documents folder through NSFileManager and get the same from the documents folder and add space to the image before adding, sorry for my English .. you need to implement your own code to save and retrieve the image through the manager files.

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

// In the printer class

  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
source

Source: https://habr.com/ru/post/898612/


All Articles