iOS:在View中打开PDF并在其上绘图并保存

时间:2015-09-08 07:48:51

标签: ios objective-c pdf uiwebview

我可以使用UIWebView打开PDF(下面的代码)。我想做的是

1)在View控制器的后台打开PDF 2)对PDF做一些评论,画上它 3)应该可以拍摄视图控制器的快照

在步骤1之上的3个步骤中,我做了3个,我坚持做第2个,如何在UIWebView上绘制

enter image description here

打开PDF的代码

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSURL *targetURL = [NSURL URLWithString:@"https://www.iscp.ie/sites/default/files/pdf-sample.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

[self.view addSubview:webView];

拍摄WebView快照的代码

-(UIImage*)captureScreen:(UIView*) viewToCapture
{
    UIGraphicsBeginImageContext(viewToCapture.bounds.size);
    [viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return viewImage;
}

0 个答案:

没有答案