【发布时间】:2015-01-06 09:14:17
【问题描述】:
我在目标 c 的 uiwebview 中加载 10 页 pdf 文件。在我想从 uiwbview 编写新的 pdf 文件之后。请哪位帮忙解答 我想写 UIWebview.scrollView。因为我在 UIWebview 滚动视图子视图中添加了一些图像。有可能
请检查我下面的代码,我在单个 pdf 页面中获得了 10 页。我不知道是什么问题?
-(void)createPDFfromUIView:(UIWebView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
NSArray *viewsToRemove1 = [self.pdfView.scrollView subviews];
for (UIView *v1 in viewsToRemove1)
{
int imgL = v1.frame.size.width;
if (imgL < 75 && imgL > 67)
{
[v1 removeFromSuperview];
aView = pdfView;
}
}
CGSize fullSize = aView.scrollView.contentSize;
NSMutableData *pdfData = [NSMutableData data];
CGRect oldFrame = aView.frame;
[aView sizeToFit];
CGRect rect = CGRectMake(aView.scrollView.contentOffset.x, aView.scrollView.contentOffset.y, fullSize.width, fullSize.height);
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, self.pdfView.scrollView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
[self.pdfView.scrollView.layer renderInContext:pdfContext];
// remove PDF rendering context
UIGraphicsEndPDFContext();
[pdfData writeToFile:getPdfpath atomically:YES];
NSLog(@"documentDirectoryFileName: %@",getPdfpath);
}
【问题讨论】:
标签: ios objective-c uiwebview