i want to save pdf to ibook from UIWebView in the app, the html in UIWebView can be multi page.
i try using
NSString *page = [self.lowWebview stringByEvaluatingJavaScriptFromString:@"document.body.outerHTML"];
NSString *path = [self exportHTMLContentToPDF:page];
NSURL *targetURL = [NSURL fileURLWithPath:path];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:targetURL];
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"itms-books:"]])
{
[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
NSLog(@"iBooks installed");
} else {
NSLog(@"iBooks not installed");
}
exportHTMLContentToPDF:
CustomPrintPageRenderer *printPageRenderer = [[CustomPrintPageRenderer alloc] init];
UIMarkupTextPrintFormatter *printFormatter = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:HTMLContent];
[printPageRenderer addPrintFormatter:printFormatter startingAtPageAtIndex:0];//.addPrintFormatter(printFormatter, startingAtPageAtIndex: 0)
NSData *pdfData = [self drawPDFUsingPrintPageRenderer:printPageRenderer];
NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *fileName = [docDirPath stringByAppendingPathComponent:@"ticket.pdf"];
[pdfData writeToFile:fileName atomically:true];//.writeToFile(fileName, atomically: true)
NSLog(@"%@", fileName);
return fileName;
the problem is exportHTMLContentToPDF create just one page if UIWebView contain multiple page, and some time the output format is not well print in pdf
thanks in advance.

Create PDF from any Microsoft Document loaded in UIWebview
First of all implement UIPrintPageRenderer protocol
Then, call below method after document finished loading in
UIWebViewExcerpted from PDF Creation in iOS - Create PDF from any Microsoft Document loaded in UIWebview. The original author was Mansi Panchal. Attribution details can be found on the contributor page. The source is licenced under CC BY-SA 3.0 and may be found in the Documentation archive. Reference topic ID: 2416 and example ID: 28437.