Hi,
i used this code for print a html document on inside my app:
Code:
-(IBAction)stampastoriaventi {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
NSLog(@"Codice lingua %@", currentLanguage);
NSLog(@"stampa storia venti");
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if(!pic){
NSLog(@"Couldn't get shared UIPrintInteractionController, need iOS 4.2 or up!");
return;
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"vent" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData: [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
if( [currentLanguage isEqualToString:@"it"] ) {
printInfo.jobName = @"LA STORIA DEI VENTI";
} else {
printInfo.jobName = @"THE STORY OF THE WINDS";
}
pic.printInfo = printInfo;
UIMarkupTextPrintFormatter *htmlFormatter = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:htmlString];
htmlFormatter.startPage = 0;
htmlFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
htmlFormatter.maximumContentWidth = 6 * 72.0;
pic.printFormatter = htmlFormatter;
[htmlFormatter release];
pic.showsPageRange = YES;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Printing could not complete because of error: %@", error);
}
};
[pic presentAnimated:YES completionHandler:completionHandler];
}
the problem is that the html document contains pictures and they do not print, how can I fix this?