0
我想使用Webview來添加一些圍繞使用Core Plot框架打印的圖形的文本。我有以下代碼似乎大部分似乎工作,但它不是顯示圖像,而是缺少圖像的問號圖像。任何人都可以點我什麼問題可能是朝着正確的方向:創建Webview打印的問題
NSData *imageData = [[barChart imageOfLayer] TIFFRepresentation];
NSString *temporaryImagePath = NSTemporaryDirectory();
NSError *error = nil;
NSBitmapImageRep* imageRep = [NSBitmapImageRep imageRepWithData:imageData];
NSData* pngData;
pngData = [imageRep representationUsingType:NSPNGFileType
properties:nil];
temporaryImagePath = [temporaryImagePath stringByAppendingPathComponent:@"pngData.png" ];
[pngData writeToFile:temporaryImagePath
options:NSDataWritingAtomic
error:&error ];
WebView *printView;
printView =[[WebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 500)
frameName:@"printFrame"
groupName:@"printGroup"];
NSMutableString *theURLString = [[NSMutableString alloc] initWithString:@"<html>"];
[theURLString appendString:@"<head>"];
[theURLString appendString:@"</head>"];
[theURLString appendString:@"<body>"];
[theURLString appendString:[NSString stringWithFormat:@"<img src=\"%@\" alt=\"Histogram\"/>", temporaryImagePath]];
[theURLString appendString:@"</body></html>"];
[[printView mainFrame] loadHTMLString:theURLString
baseURL:[NSURL URLWithString:@"a URL"]];
[[[[printView mainFrame] frameView] documentView] print:sender];
[printView release];
感謝您的幫助。當你看它時真的很明顯的錯誤。 – 2011-04-30 10:08:42