views:

28

answers:

1
self.pdfPath = [[NSBundle mainBundle] pathForResource:@"iPhone_SDK_License" ofType:@"pdf"];
NSData *htmlData = [NSData dataWithContentsOfFile:pdfPath];
    NSString *htmlstr = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];

It is showing nil in htmlstr, so need some assistance on it.

A: 

A pdf is not an html file so I assume that initWithData:encoding: just cannot understand the data and so fails.

Use stringWithContentsOfURL:encoding:error: to see the details of the error.

Mark
It is again showing garbage value so please find my code as belowcode self.pdfPath = [[NSBundle mainBundle] pathForResource:@"iPhone_SDK_License" ofType:@"pdf"]; self.pdfUrl = [NSURL fileURLWithPath:pdfPath]; [webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];NSString *myString = [NSString stringWithContentsOfURL:pdfUrl]; [fliteEngine speakText:myString]; NSLog(@"myString %@", myString);
Umaid
What encoding I should is used for pdf encoding as it is showing an error
Umaid
What does the NSError show?
Mark
pdf os a defined format including indicies not just text so a simple read and encoding will not work http://en.wikipedia.org/wiki/Portable_Document_Format
Mark
@Umaid: PDF is a binary format. Some of it is text, some of it is images, some of it is compressed data. You have absolutely no hope of just converting a PDF into a text string.
JeremyP