Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Resources
AppDelegate.cs
Info.plist
Loading a Web Page.docx
Loading a Web Page.pdf
Main.cs
README.md
WebView.csproj
WebView.sln
WebViewController.cs

README.md

id title brief sdk
5747077E-47CC-CAED-B07F-48668FBA0AAF
Load Non-Web Documents
This recipe shows how to load a web page in a UIWebView control.

Recipe

To show a document type other than HTML in a UIWebView:

  1. Add the document (for example, a PDF) to your Xamarin.iOS project. Set the Build Action to BundleResource. You can set the build action for a file by right-clicking on that file and and choosing Build Action in the menu that opens.
  1. Create a UIWebView and add it to a view:
webView = new UIWebView (View.Bounds);
View.AddSubview(webView);
  1. Load the file using NSUrl and NSUrlRequest classes:
string fileName = "Loading a Web Page.pdf"; // remember case-sensitive
string localDocUrl = Path.Combine (NSBundle.MainBundle.BundlePath, fileName);
webView.LoadRequest(new NSUrlRequest(new NSUrl(localDocUrl, false)));
webView.ScalesPageToFit = true;

Additional Information

iOS can display the following document types:

  • Excel (.xls & .xlsx)
  • Keynote (.key.zip)
  • Numbers (.numbers.zip)
  • Pages (.pages.zip)
  • PDF (.pdf)
  • PowerPoint (.ppt & .pptx)
  • Rich Text Format (.rtf)
  • Word (.doc & .docx)

See Technical Q&A 1630 for details on other supported file types.