title: Draw text on all pages of PDF using PDFKit
body: <p>I'm using the following code to draw text on a PDF Document.This seems to draw the text only on a single page.I'm trying to iterate through each page,draw string on it and finally display the PDF document from the MutableData. How do I draw the string on all pages?</p>
  <pre><code>var pdffile=PDFDocument(url: input)
  let data = NSMutableData()
  let consumer = CGDataConsumer(data: data as CFMutableData)!
  for y in stride(from: 0, to: pdffile!.pageCount, by: 1)
  {
      let page: PDFPage = pdffile!.page(at: y)!
      let outputBounds = page.bounds(for: PDFDisplayBox.mediaBox)
      var mediaBox = CGRect(x: 0, y: 0, width: outputBounds.size.width, height: outputBounds.size.height)
      let context = CGContext(consumer: consumer, mediaBox: &amp;mediaBox, nil)!
      NSGraphicsContext.current = NSGraphicsContext(cgContext: context, flipped: false)
  
      context.beginPDFPage(nil)
      page.draw(with: .mediaBox, to: context)
      text.draw(in:drawrect,withAttributes:textFontAttributes);
      context.endPDFPage()
      context.closePDF()
  }
  let anotherDocument = PDFDocument(data:data as Data)
  pdfview.document=anotherDocument
  </code></pre>