after a lot of searching and still searching, i\'m unable to find the way to extract the slides out of powerpoint presentations. Need help, if they know anything related thi
I am not sure whether this is still required. but anyways, this is how I have implemented
(1) Use UIWebView
to display the content of the PPT. The well formed (!) HTML allows you to parse it. Get the html using
NSString *htmlContent = [self.webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];
(2) Count the number of div class = 'slide
to get the slide count
(4) You need to parse the HTML to get the styles and div
using the below code
(5) Get all the styles
- (NSString *)getStyles:(int)slideCount forView:(UIWebView *)view {
NSString *getElementByTag = [[NSString alloc] init];
NSString *allStyles = [[NSString alloc] init];
for (int i = 0; i < slideCount; i++) {
getElementByTag = [NSString stringWithFormat:@"document.getElementsByTagName('style')[%d].innerHTML", i];
NSString *style = [[view stringByEvaluatingJavaScriptFromString:getElementByTag] stringByAppendingString:@"\n"];
allStyles = [allStyles stringByAppendingString:style];
}
allStyles = [@"<style type='text/css'>" stringByAppendingString: allStyles];
return [allStyles stringByAppendingString:@"</style>"];
}
(6) Concatenate all the styles from step 5 with div
tag content. Define a NSMutableArray
variable to to store all slides with styles for future reference. Define NSMutableArray *slides
to store all the slides
- (void)makeSlides:(int)slideCount forView:(UIWebView *)view {
self.slides = [[NSMutableArray alloc] init];
for (int i = 0; i < slideCount; i++) {
NSString *slideBody = [NSString stringWithFormat:@"document.getElementsByClassName('slide')[%d].innerHTML", i];
NSString *div = [view stringByEvaluatingJavaScriptFromString:slideBody];
NSString *slide = [self.slideStyles stringByAppendingString:div];
[self.slides addObject:slide];
}
}
Hope this helps