相关疑难解决方法(0)

从UIWebView创建PDF文件

 -(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
    // Creates a mutable data object for updating with binary data, like a byte array
  UIWebView *webView = (UIWebView*)aView;
    NSString *heightStr = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];

    int height = [heightStr intValue];

    // Get the number of pages needed to print. 9 * 72 = 648
    int pages = ceil(height / 648.0);

    NSMutableData *pdfData = [NSMutableData data];
    UIGraphicsBeginPDFContextToData( pdfData, CGRectZero, nil );
  CGRect frame = [webView frame];
    for (int i = 0; i < pages; i++) {
      // Check to …
Run Code Online (Sandbox Code Playgroud)

pdf core-graphics crop uiwebview ios

18
推荐指数
5
解决办法
2万
查看次数

标签 统计

core-graphics ×1

crop ×1

ios ×1

pdf ×1

uiwebview ×1