title: iOS: Splitting a UIScrollView's screenshot to multiple PDF pages for printing
body: <p>I have been trying to get UIScrollView's full length printout. I could get the UIScrollView loaded and could get a part of view in first page of Printout using below piece of code:</p>
  
  <pre><code>CGSize viewSize=((UIScrollView*)myScrollview).contentSize;
  
  CGFloat currentHeight=0;
  UIGraphicsBeginPDFContextToData(pdfData, CGRectZero, nil);
  [(UIScrollView*)myScrollview setContentOffset:CGPointMake(0, 0) animated:NO];
  
  while (currentHeight&lt;viewSize.height)
  {
      UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, viewSize.width, 792), nil);
  
      CGContextRef pdfContext = UIGraphicsGetCurrentContext();        
  
      myScrollview.bounds=CGRectMake(0,0,viewSize.width,viewSize.height);
      myScrollview.layer.bounds = CGRectMake(0, currentHeight,viewSize.width,viewSize.height);
      [myScrollview.layer renderInContext:pdfContext];
      currentHeight+=612;
  
      [(UIScrollView*)myScrollview setContentOffset:CGPointMake(0, currentHeight) animated:NO];
  }
  [(UIScrollView*)myScrollview setContentOffset:CGPointMake(0, 0) animated:NO];
  UIGraphicsEndPDFContext();
  </code></pre>
  
  <p>This code displays ScrollView's partial content in first page . I want it to split into multiple pages for printing.</p>
  
  <p>All helps are welcome.</p>