title: How to merge one pdf into another pdf file in swift 3.0.?
body: <p>I am using this code.but pdfDocumentRef3 coming nil. so its crashing.
  Please let me know where i am doing wrong. 
  let cachesDirectoryPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0]
   let filePath1 = "(cachesDirectoryPath)/ShowPdf_(self.airportMainId).pdf"
   let filePath2 = "(cachesDirectoryPath)/ImagePdf_(self.airportMainId).pdf
   let filePath3 = cachesDirectoryPath.appending("/Combine_(self.airportMainId).pdf")</p>
  
  <p>self.mergeTwoPDF(filePath1: filePath1, filePath2: filePath2, combinePath: filePath3 )</p>
  
  <pre><code>func mergeTwoPDF(filePath1: String, filePath2: String, combinePath: String) {
  
      let pdfURL1 = NSURL(fileURLWithPath: filePath1)
  
      let pdfURL2 = NSURL(fileURLWithPath: filePath2)
  
      let pdfURL3 = NSURL(fileURLWithPath: combinePath)
  
      let pdfDocumentRef1 = CGPDFDocument(pdfURL1 as CFURL)
  
      let pdfDocumentRef2 = CGPDFDocument(pdfURL2 as CFURL)
  
      let pdfDocumentRef3 = CGPDFDocument(pdfURL3 as CFURL)
  
      let numberOfPages1 = pdfDocumentRef1!.numberOfPages
  
      let numberOfPages2 = pdfDocumentRef2!.numberOfPages
  
      let writeContext = CGContext(pdfDocumentRef3 as! CFURL, mediaBox: nil, nil)
  
      var page: CGPDFPage?
      var mediaBox: CGRect
      for var i in 0..&lt;numberOfPages1 {
              page = pdfDocumentRef1!.page(at: i)
              mediaBox = page!.getBoxRect(.mediaBox)
              writeContext!.beginPage(mediaBox: &amp;mediaBox)
          writeContext!.drawPDFPage(page!)
          writeContext!.endPage()
      }
      for var i in 0..&lt;numberOfPages2 {
          page = pdfDocumentRef2!.page(at: i)
          mediaBox = page!.getBoxRect(.mediaBox)
          writeContext!.beginPage(mediaBox: &amp;mediaBox)
          writeContext!.drawPDFPage(page!)
          writeContext!.endPage()
      }
  
      writeContext!.closePDF();
  }
  </code></pre>