简体   繁体   English

在UIWebView中加载具有透明背景的pdf

[英]Load pdf with transparent background in UIWebView

I've saved a pdf with transparent background with photoshop and import in xcode. 我用Photoshop保存了透明背景的pdf文件,并导入了xcode。 I've create a webview and import the pdf like this: 我创建了一个webview并导入pdf,如下所示:

NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"PDF_da Photoshop" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSData *data = [NSData dataWithContentsOfFile:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[wv setDelegate:self];
[wv loadData:data MIMEType:@"application/pdf" textEncodingName:@"UTF-8" baseURL:nil];

No problem to see the pdf inside the webview but without a transparent background. 可以在webview中看到pdf,但是没有透明背景。

Are you expecting to see the webview underneath the PDF? 您是否希望在PDF下方看到Web视图? If so then this won't work. 如果是这样,那就行不通了。 The way UIWebView displays PDFs is by swapping its subviews out with an entirely new view. UIWebView显示PDF的方式是将其子视图换成全新的视图。 To keep the webview underneath you will need to implement your own PDF view or find an existing library, there a few on github. 为了将webview保持在下面,您将需要实现自己的PDF视图或找到现有的库,github上有一些。 A quick google brings: https://github.com/schwa/iOS-PDF-Reader and https://github.com/vfr/Reader 一个快速的谷歌带来: https : //github.com/schwa/iOS-PDF-Readerhttps://github.com/vfr/Reader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM