2011-10-04 12 views
6

मैं एयरप्रिंट का उपयोग कर UIImage प्रिंट कर रहा हूं लेकिन मार्जिन सही नहीं हैं। यह प्रिंट करता है जब यह प्रिंट करता है:
Photo of printoutएयरप्रिंट का उपयोग करके प्रिंटिंग यूआईएममेज कट ऑफ सामग्री का कारण बनता है

क्या कोई तरीका है कि मैं इसे कागज पर पूरी तरह से फिट कर सकता हूं? कि जिस तरह से आप पृष्ठ पर पूरी बात देख सकते हैं

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; 
    //pic.delegate = del; 

    UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 
    printInfo.outputType = UIPrintInfoOutputGeneral; 
    printInfo.jobName = [NSString stringWithFormat:@"New Ticket"]; 
    pic.printInfo = printInfo; 


    pic.printingItem = [UIImage imageWithContentsOfFile:path]; 

    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = 
    ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { 
     if (!completed && error) { 
      UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error." 
                message:[NSString stringWithFormat:@"An error occured while printing: %@", error] 
                delegate:nil 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil, nil]; 

      [av show]; 
      [av release]; 
     } 
    }; 

    [pic presentAnimated:YES completionHandler:completionHandler]; 
+0

आपको शायद हमें अपना कोड दिखाना होगा। कोड के साथ –

+0

अपडेट किया गया। – 0xSina

+0

यदि आप 'UIImage' प्रिंट कर रहे हैं, तो आप' UIPrintInfoOutputGeneral 'के बजाय 'UIPrintInfoOutputPhoto' पर' printInfo.outputType' क्यों सेट नहीं कर रहे हैं? –

उत्तर

0

आपका सबसे अच्छा शर्त शायद मुद्रित छवि के अनुपात के लिए नीचे छवि को मापना है,:

यहाँ कोड के रूप में अनुरोध है।

ऐसा करने के कई तरीके हैं, इसलिए मैं आपको बताऊंगा कि मैं इसे कैसे करूंगा। मैं ANImageBitmapRep नामक एक वर्ग को बनाए रखता हूं जिसमें कई प्रकार के छवि स्केलिंग होते हैं। जिस प्रकार की स्केलिंग आप चाहते हैं वह पूरी छवि रखती है, लेकिन इसे एक निश्चित आकार के आयत के अंदर केंद्रित करती है। सबसे पहले, आप अपनी परियोजना के लिए ANImageBitmapRep स्रोत फ़ाइलों को जोड़ना होगा, और ANImageBitmapRep.h #import: फिर

#import "ANImageBitmapRep.h" 

, इस तरह छवि को स्केल:

pic.printingItem = [[UIImage imageWithContentsOfFile:path] imageFittingFrame:CGSizeMake(478, 640)]; 

आप CGSizeMake(x, y) को बदल सकते हैं जो भी आप चाहते हैं, स्केल की गई छवि के पैमाने और संकल्प को समायोजित करने के लिए।

+0

हाय मैं एक ही समस्या है। http://stackoverflow.com/questions/11578013/printing-uiimage-using-epos-sdk – jongbanaag

+0

सिर्फ यह जोड़ने के लिए कि क्या ऑक्ससिना को सामग्री के बारे में समस्याएं बहुत बड़ी हैं, मुझे लगता है कि मेरा चित्र होना चाहिएफिल्मफ्रेम लेकिन मेरे पास कोई प्रश्न है यदि मैं निर्भर करता image.size.height पर मुद्रित परिणाम की ऊंचाई छोटी होगी और लंबी सामग्री को कवर करने के लिए पर्याप्त नहीं होगी। कोई विचार? धन्यवाद – jongbanaag

संबंधित मुद्दे