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];     
    }
  • 相关阅读:
    Thinkphp各种方法知识图谱
    Yii2.0学习笔记:创建登录表单
    Yii2.0学习笔记:第一个页面Saying Hello
    4.1
    4
    flask(3.0)
    flask(2.0)
    flask(1.1)装饰器装饰多个视图函数出现的问题
    flask(1.0)
    Flask之上下文管理机制
  • 原文地址:https://www.cnblogs.com/liulixiang/p/3535924.html
Copyright © 2011-2022 走看看