Load text+pdf file in uiwebview

别等时光非礼了梦想. 提交于 2019-12-12 02:06:16

问题


I want to show some text and pdf file in a webview at a time.

is there any possibility..

i had tried using

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

This shows the text and only the first page of pdf file,..

Thanks in advance


回答1:


Use another way to load pdf and above the webView add a UILabel to show the text. As you see pdf is treated as a image so that only one page is showed.

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


来源:https://stackoverflow.com/questions/26751419/load-textpdf-file-in-uiwebview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!