title: iOS - Creating multi page PDF from HTML content
body: <p>I have a long html page and wanted to convert it in to a multipage PDF file.</p>
  
  <p>I have followed the instructions provided in
  <a href="http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GeneratingPDF/GeneratingPDF.html" rel="nofollow noreferrer">apple</a> and <a href="https://stackoverflow.com/a/3490719/401355">here - how to make multi page PDF</a> for a given string content.</p>
  
  <p>But the formatting the NSString ( with some  like data ) is difficult than creating a html page. I have created this html and displaying it in a UIWebView.</p>
  
  <p>Now I want to create a PDF out of this HTML to a <b>Multi page</b> PDF file.</p>
  
  <p>The code I'm using can create single PDF.</p>
  
  <pre>
  - (void)createPDFfromUIView:(UIWebView *)aView saveToDocumentsWithFileName:(NSString*)aFilename
  {
      // Creates a mutable data object for updating with binary data, like a byte array
      NSMutableData *pdfData = [NSMutableData data];
  
      // Points the pdf converter to the mutable data object and to the UIView to be converted
      UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
      UIGraphicsBeginPDFPage();
      CGContextRef pdfContext = UIGraphicsGetCurrentContext();
  
  
      // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
  
      [aView.layer renderInContext:pdfContext];
  
      // remove PDF rendering context
      UIGraphicsEndPDFContext();
  
      // Retrieves the document directories from the iOS device
      NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
  
      NSString* documentDirectory = [documentDirectories objectAtIndex:0];
      NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename];
  
      // instructs the mutable data object to write its context to a file on disk
      [pdfData writeToFile:documentDirectoryFilename atomically:YES];
      NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
  }
  </pre>
  
  <p>Can any one give some help ?</p>