title: How to generate pdf using NSData or using data bytes objective c?
body: <p>Hi I want to write pdf using <code>NSData</code> or using data bytes given by webservice ?</p>
  
  <pre><code>    -(NSData *)saveData:(NSData*)fileData fileName:(NSString *)fileName fileType:(NSString *)fileType
  {
      NSFileManager *fileManager = [NSFileManager defaultManager];
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
      NSString *documentsDir = [paths objectAtIndex:0];
  
      NSString *filePath = [NSString stringWithFormat:@"%@/%@.%@",documentsDir,fileName,fileType];
  
      NSData* downloadData = [NSData dataWithData:fileData];
  
      [fileManager createFileAtPath:filePath contents:downloadData attributes:nil];
  
  
  }
  </code></pre>
  
  <p>I am using this but it's not working it's give me error "It may be damaged or use a file format that Preview doesn’t recognize." on opening that pdf created by above code. </p>