Q:

Write PDF file from UIWebView.scrollView in objective c

I load 10 page pdf file in uiwebview in objective c. After I want to write new pdf file from uiwbview.  Please any one help to answer 
i want to write UIWebview.scrollView.  Because i have added some image in UIWebview scrollview subview .  its possible 
Please check my below code im getting 10 pages in single pdf page.  I dont know what the issues ?  
-(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);
   }

A:

You can use something like this to load the PDF into an NSData object:
NSData *pdfFile = [NSData dataWithContentsOfURL:webView.request. URL];
Then, you can use the NSData methods to write the data to a file:
[pdfFile writeToFile:filePath atomically:YES];
Of course, you'll need to setup filePath to be an appropriate writable location to store the file/

