Saif
Saif

Reputation: 2958

Load text+pdf file in uiwebview

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

Upvotes: 0

Views: 576

Answers (1)

gabbler
gabbler

Reputation: 13766

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

Upvotes: 1

Related Questions