too much lines advance before print



I´m newbie on mobile Develop


Could you give me advice about this ? .... Thanks, Regards



I have one app on iOS (Xcode 7.1) , the app build a PDF file and then this file send via bluetooth to print on iMZ320 printer and works fine I have one issue:


When the PDF file is created, I don't see too much lines(spaces) on the beginning or ending (you can see on cedula.png file)


So, when the file it's send to the printer, before the printer advanced much lines before print the file(you can see on ticket.jpeg file, how many spaces are between two print)


The code when touch the printer icon:


- (IBAction)printButton:(id<GraphicsUtil, NSObject>) graphicsUtil {

   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^ {  

    NSString* fileName = [self getPDFFileName];

    CFURLRef pdfURL = (CFURLRef)CFBridgingRetain([NSURL fileURLWithPath:fileName]);

    if (pdfURL != NULL) {

        CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);

        if (pdf == NULL) {

            [self performSelectorOnMainThread:@selector (showErrorDialog:) withObject:@"Could not retrieve PDF document." waitUntilDone:YES];

        } else {

            size_t nPages = CGPDFDocumentGetNumberOfPages(pdf);

            size_t pageNum;

            BOOL success = NO;

            for (pageNum = 1; pageNum <= nPages; pageNum++) {             

                UIImage* image = [self imageFromPDF:pdf page:pageNum];

                if (nil == image) {

                    [self performSelectorOnMainThread:@selector(showErrorDialog:) withObject:@"Could not render PDF document." waitUntilDone:YES];



                [self setZebraPrinter];             

                NSError *error = nil;             

                success = [[self.printer getGraphicsUtil] printImage:[image CGImage] atX:0 atY:0 withWidth:-1 withHeight:-1

                                 andIsInsideFormat:NO error:&error];            

                if(success == NO) {

                    [self performSelectorOnMainThread:@selector(showErrorDialog:) withObject:[error localizedDescription] waitUntilDone:YES];




            if (success == YES) {

                NSString *successMessage = @"Image sent to printer";

                [self performSelectorOnMainThread:@selector(showSuccessDialog:) withObject:successMessage waitUntilDone:YES];












    NSString* fileName = @"Cedula.PDF";   

    NSArray *arrayPaths =





    NSString *path = [arrayPaths objectAtIndex:0];

    NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];

    return pdfFileName;




-(UIImage *)imageFromPDF:(CGPDFDocumentRef)pdf

                    page:(NSUInteger)pageNumber {   

    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber);   

    CGRect rect = CGPDFPageGetBoxRect(page, kCGPDFArtBox);  

    UIImage *resultingImage = nil;   


    CGContextRef context = UIGraphicsGetCurrentContext();   

    CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();

    const CGFloat fillColors[] = {1, 1, 1, 1};   

    CGColorRef colorRef = CGColorCreate(rgb, fillColors);

    CGContextSetFillColorWithColor(context, colorRef);

    CGContextFillRect(context, rect);



    CGContextTranslateCTM(context, 0.0, rect.size.height);  

    CGContextScaleCTM(context, 1.0, -1.0); 

    if (page != NULL) {


        CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, rect, 0, true);     

        CGContextConcatCTM(context, pdfTransform);     

        CGContextDrawPDFPage(context, page);     


        resultingImage = UIGraphicsGetImageFromCurrentImageContext();



    return resultingImage;


Gregory Pawlik
Hi Joaquin,The printer most

Hi Joaquin,

The printer most likely needs to be set for continuous mode.

You can do this using the Zebra Setup Utilities.

Make sure you have the iMZ320-ZPL driver installed and open the Zebra Setup Utilities and select the printer. 

Click on “Configure Printer Settings” and next through until you get to the Media_Type option.

Set it to Continuous and click Finish.

Hope this helps.


Vote up!
Vote down!

Points: 0

You voted ‘up’

Joaquin vt9yxeu...
Hi Greg, thanks for you

Hi Greg, thanks for you answer.

Where can I donwload the Zebra Setup Utilities?

Vote up!
Vote down!

Points: 0

You voted ‘up’

Gregory Pawlik
Hi Joaquin,The Zebra Setup

Hi Joaquin,

The Zebra Setup Utilities can be downloaded from the following page:

Support & Downloads for the iMZ320 Mobile Printer | Zebra


Vote up!
Vote down!

Points: 1

You voted ‘up’

Log in to post comments