zoukankan      html  css  js  c++  java
  • iOS显示PDF

    使用UIWebView来显示

    //locale file
    NSString *html = [NSString stringWithContentsOfFile:path1 encoding:NSUTF8StringEncoding error:nil];
    [self.webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]]];
    //或者
    NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
    NSURL *targetURL = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [webView loadRequest:request];
    
    //remote file
    - (void) loadRemotePdf
        {
           CGRect rect = [[UIScreen mainScreen] bounds];
           CGSize screenSize = rect.size;
            
           UIWebView *myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,screenSize.width,screenSize.height)];
           webView.autoresizesSubviews = YES;
           webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
    
           NSURL *myUrl = [NSURL URLWithString:@"http://www.mysite.com/test.pdf"];
           NSURLRequest *myRequest = [NSURLRequest requestWithURL:myUrl];
                
           [webView loadRequest:myRequest];
    
           [window addSubview: myWebView];
           [myWebView release];     
    }
  • 相关阅读:
    转载--gulp入门
    grunt之easy demo
    CentOS下vm虚拟机桥接联网
    Webstorm & PhpStorm
    2.使用Package Control组件安装
    virtual方法和abstract方法
    sql server 2008 跨服务器查询
    .NET开源项目常用记录
    vs2010 安装MVC 3.0
    所有运行命令指令大全
  • 原文地址:https://www.cnblogs.com/liulixiang/p/3535924.html
Copyright © 2011-2022 走看看