2010-07-29 38 views
0
self.pdfPath = [[NSBundle mainBundle] pathForResource:@"iPhone_SDK_License" ofType:@"pdf"]; 
NSData *htmlData = [NSData dataWithContentsOfFile:pdfPath]; 
NSString *htmlstr = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; 

它在htmlstr中显示为零,因此需要一些帮助。无法检索字符串中的数据

+0

您需要进一步调试。是pdfPath无? htmlData是否为零? – jtbandes 2010-07-29 06:27:25

回答

0

pdf不是一个html文件,所以我认为initWithData:encoding:就是不能理解数据,所以失败了。请使用stringWithContentsOfURL:encoding:error:查看错误的详细信息。

+0

它再次显示垃圾值,所以请找到我的代码如下 代码 self.pdfPath = [[NSBundle mainBundle] pathForResource:@“iPhone_SDK_License”ofType:@“pdf”]; \t self.pdfUrl = [NSURL fileURLWithPath:pdfPath]; \t [webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]]; NSString * myString = [NSString stringWithContentsOfURL:pdfUrl]; \t [fliteEngine speakText:myString]; \t NSLog(@“myString%@”,myString); – Umaid 2010-07-29 06:53:53

+0

什么编码我应该用于pdf编码,因为它显示一个错误 – Umaid 2010-07-29 08:15:44

+0

什么是NSError显示? – Mark 2010-07-29 08:59:19