Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert Byte Array to PDF File IOS
    primarykey
    data
    text
    <p>I have the following code to call the webservice that returns <code>byte[]</code> for PDF File. Is there something wrong ? it is generating the corrupt PDF file.</p> <p><strong>More Details</strong></p> <p>IOS send request for the pdf file through Webservice which is written in .Net Framework. The webservice returns Array of Bytes for the PDF File. Now what i need to do is capture the Array of Bytes and convert it into PDF file in IOS. </p> <p>The following piece of code is my try to do that </p> <pre><code>@try { NSString *baseURL = @"http://host/service/GetPDF"; NSLog(@"Service URL : %s\n", [baseURL UTF8String]); NSURL *serviceURL = [NSURL URLWithString: baseURL]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL: serviceURL]; [request setHTTPMethod:@"POST"]; [request setTimeoutInterval:30.0]; NSURLResponse *response = NULL; NSError *requestError = NULL; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;requestError]; NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]]; NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"myPDF.pdf"]; NSData* pdfData = [NSData dataWithBytes:[responseData bytes] length:[responseData length]]; [pdfData writeToFile:filePath atomically:YES]; } @catch (NSException* ex) { NSLog(@"doSomethingFancy failed: %@",ex); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload