title: Create pdf of tableview all data
body: <p>I have create pdf of tableview all cells. but i have create the pdf it does not show all data of tableview &amp; also when pdf page height set according to cells data. I dont know how to resolve this issue. I am using this code for create pdf.please help me.</p>
  
  <pre><code>  let _: NSData!
          do {
              let priorBounds = table_view.bounds
              let fittedSize = table_view.sizeThatFits(CGSizeMake(priorBounds.size.width, .infinity))
              table_view.bounds = CGRectMake(0, 0, fittedSize.width, fittedSize.height)
              let pdfPageBounds = CGRectMake(0, 0, 612, 800)
              let pdfData = NSMutableData()
              UIGraphicsBeginPDFContextToData(pdfData, pdfPageBounds, nil)
              do {
                  var pageOriginY = 0
                  while pageOriginY &lt; Int(fittedSize.height)  {
                      UIGraphicsBeginPDFPageWithInfo(pdfPageBounds, nil)
                      CGContextSaveGState(UIGraphicsGetCurrentContext()!)
                      do {
                          CGContextTranslateCTM(UIGraphicsGetCurrentContext()!, 0, -CGFloat(pageOriginY))
                          table_view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
                      }
                      CGContextRestoreGState(UIGraphicsGetCurrentContext()!)
                      pageOriginY += Int(pdfPageBounds.size.height)
                  }
              }
              UIGraphicsEndPDFContext()
              table_view.bounds = priorBounds
              if let documentDirectories = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first {
                  let documentsFileName = documentDirectories + "/" + (filename as String)
                  debugPrint(documentsFileName)
                  pdfData.writeToFile(documentsFileName, atomically: true)
              }
          }
  </code></pre>