2

We can see the file details from the properties of file as mentioned in the below image.

enter image description here

The same details I need it programmatically using Nodejs or Angularjs. I don't think file operations can be done from Angularjs. Is it possible to obtain the same information of a file in node, I guess shellsjs would support but I am not aware of which method exists for the same.

This would yield in checking Word document, PDF, etc as well for Protractor testing.

halfer
  • 19,824
  • 17
  • 99
  • 186
Mithun Shreevatsa
  • 3,588
  • 9
  • 50
  • 95

1 Answers1

1

A PowerPoint file is simply a bunch of mostly XML files zipped. Thus, you can unzip the file to get access to whatever you want. For example, I extracted an empty 1-slide presentation file called "test.pptx" using 7-zip and got this:

enter image description here

Now, this is the app.xml file:

<?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>

As you can see, among other things, it includes the number of slides. In other words, simply unzip the presentation file using your choice of the several available unzipping NPM packages and read the XML file inside it.

Roope
  • 4,469
  • 2
  • 27
  • 51