在uiwebview中加载文本+pdf文件



我想一次在网络视图中显示一些文本和pdf文件。

有可能吗。。

我试过使用

NSString *htmlString = [NSString stringWithFormat:@"<p>some text which i need to show above pdf</p><img src="file://%@">",@"FR.pdf"];
NSString *bundleP = [[NSBundle mainBundle] resourcePath];
NSURL *fileURL = [NSURL fileURLWithPath:bundleP];
[pdfWebView loadHTMLString:htmlString baseURL:fileURL];

这显示了文本,并且只显示了pdf文件的第一页,。。

提前感谢

使用另一种方式加载pdf,并在webView上方添加一个UILabel以显示文本。如您所见,pdf被视为image,因此只显示一个页面。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FR" ofType:@"pdf"];
NSURL *filePathURL = [NSURL fileURLWithPath:filePath];
[self.webView loadRequest:[NSURLRequest requestWithURL:filePathURL]];

最新更新