0

I am trying to create a PDF file with a buch of data. The PDF has 7 pages, contains text, images and charts and works fine so far. Now I have to add a html-table to one of the PDFs pages. In that ViewController I added a WebView and try loading the data in the background, then printing it to the file. When presenting the ViewController, the WebView does load the page. But I need it to load while not being presented, my current problem is that the UIWebView stays white in the PDF-file: webViewDidStartLoad:(UIWebView *)webView is not being called.

Code VC1:

PDFPage6ViewController *pdf2 = [self.storyboard instantiateViewControllerWithIdentifier:@"PDF6"];
pdf2.controlIdentifier = controlIdentifier;
pdf2.startDate = startDate;
pdf2.endDate = endDate;

UIGraphicsBeginPDFContextToData(pdfData, CGRectZero,nil);
CGContextRef pdfContext=UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPage();
[pdf2.view.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();

Code PDF2:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self getDataFromDatabase];
}


- (void)getDataFromDatabase {
    /*loading data*/
    [self processData];
}

- (void)processData {
    /*doing some calculations*/
    NSString *html = /*creating the html string*/
    [webView loadHTMLString:html baseURL:nil];
}
4

0 回答 0