title: One of the best way to convert tableView into mutiple pages PDF in Swift, iOS
body: <p>Use this function to get mutiple pages pdf Version of your tableView, just pass your tableView name to this function :-</p>
  
  <pre><code>func pdfDataWithTableView(tableView: UITableView) {
  
  
          let priorBounds = tableView.bounds
          let fittedSize = tableView.sizeThatFits(CGSizeMake(priorBounds.size.width, tableView.contentSize.height))
          tableView.bounds = CGRectMake(0, 0, fittedSize.width, fittedSize.height)
          let pdfPageBounds = CGRectMake(0, 0, tableView.frame.width, self.view.frame.height)
          let pdfData = NSMutableData()
          UIGraphicsBeginPDFContextToData(pdfData, pdfPageBounds,nil)
          var pageOriginY: CGFloat = 0
          while pageOriginY &lt; fittedSize.height {
              UIGraphicsBeginPDFPageWithInfo(pdfPageBounds, nil)
              CGContextSaveGState(UIGraphicsGetCurrentContext())
              CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, -pageOriginY)
              tableView.layer.renderInContext(UIGraphicsGetCurrentContext()!)
              CGContextRestoreGState(UIGraphicsGetCurrentContext())
              pageOriginY += pdfPageBounds.size.height
          }
          UIGraphicsEndPDFContext()
          tableView.bounds = priorBounds
  
          var docURL = (NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)).last! as NSURL
          docURL = docURL.URLByAppendingPathComponent( "myDocument.pdf")
          pdfData.writeToURL(docURL, atomically: true)
      }
  </code></pre>