title: Posting Pdf from facebook and twitter activity controller
body: <p>I have a code that converts my <code>UIView</code> to pdf. Now I want to be able to use this PDF in the <code>UIActivityController</code> for Facebook and Twitter integration. I don't know how to go about it, but the code for the PDF is displayed below:</p>
  
  <pre><code>-(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
  {
      // Creates a mutable data object for updating with binary data, like a byte array
      NSMutableData *pdfData = [NSMutableData data];
      // Points the pdf converter to the mutable data object and to the UIView to be converted
      UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
      UIGraphicsBeginPDFPage();
      CGContextRef pdfContext = UIGraphicsGetCurrentContext();
  
  
      // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
  
      [aView.layer renderInContext:pdfContext];
  
      // remove PDF rendering context
      UIGraphicsEndPDFContext();
  
      // Retrieves the document directories from the iOS device
      NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
  
      NSString* documentDirectory = [documentDirectories objectAtIndex:0];
      NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename];
  
      // instructs the mutable data object to write its context to a file on disk
      [pdfData writeToFile:documentDirectoryFilename atomically:YES];
      NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
  }
  </code></pre>
  
  <p>How do I initialize the PDF for posting in Facebook and Twitter and even email?</p>