Printing UIImage using ePOS SDK
Asked Answered
T

1

0

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)

I'm loading an 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 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];

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

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.

enter image description here

Theodoratheodore answered 20/7, 2012 at 11:2 Comment(2)
anyone have a solution for this?Entomb
i suggest you that create your bill image according to paper sizeGstring
O
0

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 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];
}
Ormand answered 9/2, 2013 at 14:23 Comment(2)
tried your approach. But the image is not that good in quality. Also iused UIViewContentModeScaleAspectToFillTheodoratheodore
can you show me your receipt photo and update your answer with resizedImageContentMode methodGstring

© 2022 - 2024 — McMap. All rights reserved.