- (IBAction)makePDF:(id)sender { // the follow method is meant to convert a webview in a multipage PDF. // for our app we need it in memory, but to date have only got it working // when we generate a file. // what I want is to be able to set shouldGenrateFile to NO and have // it generate the PDF properly in memory so I can display it. NSLog(@"Make PDF..."); // if this is true we'll use the print system to generate a file // else we'll generate an in memory pdf to display. BOOL shouldGenrateFile = YES; NSMutableData *data = [NSMutableData data]; NSPrintOperation *printOp; NSPrintInfo *printInfo; NSPrintInfo *sharedInfo; NSMutableDictionary *printInfoDict; NSMutableDictionary *sharedDict; sharedInfo = [NSPrintInfo sharedPrintInfo]; sharedDict = [sharedInfo dictionary]; printInfoDict = [NSMutableDictionary dictionaryWithDictionary: sharedDict]; if (shouldGenrateFile) { [printInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition]; [printInfoDict setObject:@"/Users/zorn/Desktop/web.pdf" forKey:NSPrintSavePath]; } printInfo = [[NSPrintInfo alloc] initWithDictionary: printInfoDict]; [printInfo setHorizontalPagination: NSAutoPagination]; [printInfo setVerticalPagination: NSAutoPagination]; [printInfo setVerticallyCentered:NO]; NSView *viewToPrint = [[[webView mainFrame] frameView] documentView]; if (shouldGenrateFile) { // if we printOp = [NSPrintOperation printOperationWithView:viewToPrint printInfo:printInfo]; [printOp setShowPanels:NO]; [printOp runOperation]; } else { printOp = [NSPrintOperation PDFOperationWithView:viewToPrint insideRect:[viewToPrint frame] toData:data printInfo:printInfo]; [printOp runOperation]; [pdf release]; pdf = [[PDFDocument alloc] initWithData:data]; [pdfView setDocument:pdf]; } }