本文介绍了IOS库将powerpoint演示文稿转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过大量搜索并仍在搜索之后,我无法找到从幻灯片演示文稿中提取幻灯片的方法。需要帮助,如果他们知道任何相关的内容或已经实现了这样的事情,源代码将是伟大的或任何参考链接也将工作。我一直在使用QLPreviewController,但是我没能覆盖它。

解决方案

我不确定这是否仍然需要。但无论如何,这就是我实现的方式



(1)使用 UIWebView 来显示PPT的内容。格式良好的(!)HTML允许您解析它。使用

获取html

  NSString * htmlContent = [self.webView stringByEvaluatingJavaScriptFromString:@document.body.innerHTML]; 

(2)计算 div class ='slide 获取幻灯片计数



(4)您需要解析HTML以获取样式并 div 使用以下代码



(5)获取所有样式

   - (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 , 一世];
NSString * style = [[view stringByEvaluatingJavaScriptFromString:getElementByTag] stringByAppendingString:@\ n];
allStyles = [allStyles stringByAppendingString:style];
}

allStyles = [@< style type ='text / css'> stringByAppendingString:allStyles];

返回[allStyles stringByAppendingString:@< / style>];
}

(6)将步骤5中的所有样式与 div 标记内容。定义 NSMutableArray 变量以存储所有带样式的幻灯片以供将来参考。定义 NSMutableArray * slide 以存储所有幻灯片

   - (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];
}
}

希望这会有所帮助


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 this or have implemented such thing, source code will be great or any reference link will also work. I have been using QLPreviewController, but i failed to override it.

解决方案

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

这篇关于IOS库将powerpoint演示文稿转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 20:17
查看更多