title: Converting a PDF image to NSData for Parse.com in Swift
body: <p>I am creating PDFs in my application and want to upload them to Parse.com. I need to first convert the PDF images to <code>NSData</code> before uploading. I know it is possible in Objective-C:</p>
  
  <pre><code>NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"test.pdf"];
  NSData *myData = [NSData dataWithContentsOfFile:pdfPath];
  </code></pre>
  
  <p>However, is it possible to convert a PDF file to <code>NSData</code> in Swift? The following does not work:</p>
  
  <pre><code>var pdfPath: String = documentsDirectory.stringByAppendingPathComponent("test.pdf")
  var myData: NSData = NSData.dataWithContentsOfFile(pdfPath)
  </code></pre>
  
  <p>Relevant links:</p>
  
  <p><a href="https://stackoverflow.com/questions/28849795/converting-a-pdf-image-to-nsdata-for-parse-com">Converting a pdf image to NSData for Parse.com</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7535635/put-pdf-into-nsdata">Put PDF into NSData</a></p>