4

I fall into this problem for a long time. as I asked, I can print the scrollview but only a part of it, not the full size view "contentView".

the code is like this:

if ([UIPrintInteractionController isPrintingAvailable])
{
    UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
    UIGraphicsBeginImageContext(sv.contentSize);

    [sv.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData *myData = [NSData dataWithData:UIImagePNGRepresentation(viewImage)];
    if(pic && [UIPrintInteractionController canPrintData: myData] ) {

        pic.delegate =(id<UIPrintInteractionControllerDelegate>) self;

        UIPrintInfo *printInfo = [UIPrintInfo printInfo];
        printInfo.outputType = UIPrintInfoOutputGeneral;
        printInfo.jobName = [NSString stringWithFormat:@"QFTicket-%@",self.payment.id];
        printInfo.duplex = UIPrintInfoDuplexLongEdge;
        pic.printInfo = printInfo;
        pic.showsPageRange = YES;
        pic.printingItem = myData;
        pic.printFormatter=[sv viewPrintFormatter];

        void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
            if (!completed && error) {
                NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
            }
        };

        [pic presentAnimated:YES completionHandler:completionHandler];

    }

}

Am I missing something?

thx

Travis Worm
  • 166
  • 8
  • 1
    I think I got the answer: http://stackoverflow.com/questions/3539717/getting-a-screenshot-of-a-uiscrollview-including-offscreen-parts – Travis Worm May 03 '11 at 07:59

0 Answers0