2015-09-17 36 views
3

以下是我目前做的, 我的应用程序可以与值在PDF表单填写相应字段,并生成一个PDF的新副本。好吧,它可以正常工作,并按照我的意愿获得预期的结果。 但我的问题是, 当我想查看生成的PDF文件填充数据时,它不显示我的IPAD。IOS没有显示在网页视图填充PDF表单填写文本

Here is the end result of my filled form which I grab from the container of my IPAD

Here is what it display in my IPAD

我抓住从IPAD集装箱生成的PDF文件,它能够表现出在的MacBook在各自领域的文本,但无法在IOS中显示。 这里是我的Objective-C代码:

NSString *txtFilePath = [[self getDocumentsFolder] stringByAppendingPathComponent:@"geForm1.pdf"]; 

NSURL *targetURL = [NSURL fileURLWithPath:txtFilePath]; 
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; 
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL]; 
CGFloat height = [[UIScreen mainScreen] bounds].size.height; 
CGFloat width = [[UIScreen mainScreen] bounds].size.width; 
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; 
[webView loadRequest:request]; 
[self.view addSubview:webView]; 

我不知道是我犯的错误造成的数据填充未在IOS中。

UPDATE:

我试图在开放的iBook的PDF文件,它不具有各自的领域内的任何值。该文件是空白的。然后我尝试在Adobe Reader中打开PDF文件,并感谢上帝所有的文本显示在各自的领域。

现在我的问题,如何使默认/生PDF阅读器或Web视图中显示那些充满文本?

+0

pdf文件“txtFilePath”路径包含“geForm1.pdf”文件 – Jamil

+0

烨,它包含了正确的文件。否则什么都不会出现。 –

+0

你会给“txtFilePath”和“pdfData”的日志吗? – Jamil

回答

0

它适用于我的情况。

-(void)readPDFFile{ 
// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
// NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder 
// NSString *txtFilePath = [documentsDirectory stringByAppendingPathComponent:@"geForm1.pdf"]; 
NSString *txtFilePath = [[NSBundle mainBundle] pathForResource:@"geForm1" ofType:@"pdf"]; 
NSLog(@"txtFilePath:%@",txtFilePath); 

NSURL *targetURL = [NSURL fileURLWithPath:txtFilePath]; 
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; 
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL]; 
CGFloat height = [[UIScreen mainScreen] bounds].size.height; 
CGFloat width = [[UIScreen mainScreen] bounds].size.width; 
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; 
[webView loadRequest:request]; 
[self.view addSubview:webView]; 

}

注:我读的第一次检查,从应用程序的文件夹捆绑