如何使用Nodejs从上传的ppt文件中获取幻灯片数量?

时间:2016-06-29 07:42:23

标签: javascript angularjs node.js shell protractor

我们可以从文件属性中看到文件详细信息,如下图所示。

enter image description here

我使用Nodejs或Angularjs以编程方式需要它的相同细节。我不认为文件操作可以从Angularjs完成。是否有可能获得节点中文件的相同信息,我想shelljs会支持但我不知道存在哪种方法。

这将在检查Word文档,PDF等以及Protractor测试时产生。

1 个答案:

答案 0 :(得分:0)

PowerPoint文件只是一堆压缩了大部分XML文件。因此,您可以解压缩文件以访问所需的任何内容。例如,我使用7-zip提取了一个空的1幻灯片演示文稿文件“ test.pptx”,并得到了这个文件:

enter image description here

现在,这是app.xml文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
    <TotalTime>0</TotalTime>
    <Words>0</Words>
    <Application>Microsoft Office PowerPoint</Application>
    <PresentationFormat>Widescreen</PresentationFormat>
    <Paragraphs>0</Paragraphs>
    <Slides>1</Slides>
    <Notes>0</Notes>
    <HiddenSlides>0</HiddenSlides>
    <MMClips>0</MMClips>
    <ScaleCrop>false</ScaleCrop>
    <HeadingPairs>
        <vt:vector size="6" baseType="variant">
            <vt:variant>
                <vt:lpstr>Fonts Used</vt:lpstr>
            </vt:variant>
            <vt:variant>
                <vt:i4>3</vt:i4>
            </vt:variant>
            <vt:variant>
                <vt:lpstr>Theme</vt:lpstr>
            </vt:variant>
            <vt:variant>
                <vt:i4>1</vt:i4>
            </vt:variant>
            <vt:variant>
                <vt:lpstr>Slide Titles</vt:lpstr>
            </vt:variant>
            <vt:variant>
                <vt:i4>1</vt:i4>
            </vt:variant>
        </vt:vector>
    </HeadingPairs>
    <TitlesOfParts>
        <vt:vector size="5" baseType="lpstr">
            <vt:lpstr>Arial</vt:lpstr>
            <vt:lpstr>Calibri</vt:lpstr>
            <vt:lpstr>Calibri Light</vt:lpstr>
            <vt:lpstr>Office Theme</vt:lpstr>
            <vt:lpstr>PowerPoint Presentation</vt:lpstr>
        </vt:vector>
    </TitlesOfParts>
    <LinksUpToDate>false</LinksUpToDate>
    <SharedDoc>false</SharedDoc>
    <HyperlinksChanged>false</HyperlinksChanged>
    <AppVersion>16.0000</AppVersion>
</Properties>

如您所见,它包括幻灯片的数量。换句话说,只需使用几种可用的NPM压缩包来解压缩演示文稿文件,然后读取其中的XML文件。

相关问题