view to PDF not capturing all information

The below code captures most of the information on the screen. When I click the share icon the view changes, and when I try scrolling the screen bounces. It's cutting off the bottom information that is not in the display

   func createPdfFromTableView()
{
    let priorBounds: CGRect = self.tableView.bounds
    let fittedSize: CGSize = self.tableView.sizeThatFits(CGSize(width: priorBounds.size.width, height: self.tableView.contentSize.height))
    self.tableView.bounds = CGRect(x: 0, y: 0, width: fittedSize.width, height: fittedSize.height)
    self.tableView.reloadData()
    let pdfPageBounds: CGRect = CGRect(x: 0, y: 0, width: fittedSize.width, height: (fittedSize.height))

    ///
    let pdfData: NSMutableData = NSMutableData()
    UIGraphicsBeginPDFContextToData(pdfData, pdfPageBounds, nil)
    UIGraphicsBeginPDFPageWithInfo(pdfPageBounds, nil)

    self.tableView.layer.render(in: UIGraphicsGetCurrentContext()!)
    UIGraphicsEndPDFContext()
    let documentDirectories = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
    let documentsFileName = documentDirectories! + "/" + "PC - \(plBranch) - \(plDate).pdf"
    pdfData.write(toFile: documentsFileName, atomically: true)


    let url = URL(fileURLWithPath: documentsFileName)


    // pass created file to shareView

           let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)

         present(activityController, animated: true, completion: nil)
}