title: Saving a CGPDFDocumentRef to File
body: <p>I am having a hard time searching for this question, is there no one can answer this question?
  I am hoping for a good answer with example. follow this question <a href="https://stackoverflow.com/questions/6763942/iphone-pdf-encryption">iPhone - pdf encryption</a> but I think PDFDocument class only exists in mac os.and this is similar to this question <a href="https://stackoverflow.com/questions/6729911/reading-with-cgpdfdocumentref-and-saving-pdf">reading with CGPDFDocumentRef and saving PDF</a> haven't got an answer. :(</p>