【问题标题】:IOS does not show filled PDF form filled text in webviewIOS在webview中不显示填充的PDF表单填充文本
【发布时间】:2015-12-13 21:51:43
【问题描述】:

这是我目前正在做的事情, 我的应用程序可以使用相应字段中的值填写 PDF 表单并生成 PDF 的新副本。好的,它工作正常并如我所愿获得预期的结果。 但我的问题是, 当我想查看生成的填充了数据的 PDF 文件时,它在我的 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中没有显示填充数据的错误。

更新:

我尝试在 iBook 中打开 pdf 文件,但在相应字段中没有任何值。文档是空白的。然后我尝试在 Adob​​e Reader 中打开 pdf 文件,感谢上帝,所有文本都显示在相应的字段中。

现在我的问题是,如何在默认/本机 pdf 查看器或网络视图上显示那些填充的文本?

【问题讨论】:

  • 首先检查'txtFilePath'路径是否包含'geForm1.pdf'文件
  • 是的,它包含正确的文件。否则什么都不会出现。
  • 能否给出“txtFilePath”和“pdfData”的日志?
  • 在我的例子中 "NSString *txtFilePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];"我得到显示 pdf 的结果
  • 我在阅读 pdf 文件时没有遇到任何问题。但我的问题是显示的 pdf 文件未在相应字段中填写数据或文本。

标签: ios objective-c ipad pdf


【解决方案1】:

它适用于我的情况。

-(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];

}

注意:我从应用程序的捆绑文件夹中读取 pdf 文件

【讨论】:

    猜你喜欢
    • 2023-03-20
    • 2021-09-26
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    相关资源
    最近更新 更多