w3nl / ppt-png

Convert ppt to png
MIT License
45 stars 7 forks source link

TypeError: this.files.pop is not a function #3

Closed pankajDevFrontend closed 5 years ago

pankajDevFrontend commented 5 years ago

Getting this error here is my code

import Converter from 'ppt-png';

  new Converter({
      files: files,
      output: 'output/',
      invert: true,
      callback: function (data) {
        console.log(data.failed, data.success, data.files, data.time);
      }
    }).run();

Screenshot 2019-08-13 at 12 03 19 PM

w3nl commented 5 years ago

Is in your code files an array?

pankajDevFrontend commented 5 years ago

Is in your code files an array?

nope, it's just single file.

w3nl commented 5 years ago

Ok, the current code can only handle an array.

You can e.g. send an array with the single file.

new Converter({
      files: [file],
pankajDevFrontend commented 5 years ago

th the single file.

ok let me check with this solution.

pankajDevFrontend commented 5 years ago

Ok, the current code can only handle an array.

You can e.g. send an array with the single file.

new Converter({
      files: [file],

error resolved but not getting response.

callback: function (data) {
        console.log(data.failed, data.success, data.files, data.time);
      }

there is no response or any error getting inside the callback function.

w3nl commented 5 years ago

Can you provide more details? What is the response message? Can you provide more code?

callback: function (data) {
        console.log(data);
      }

(Can you give all information)

pankajDevFrontend commented 5 years ago

ovide more code?

Here is full code

var Converter = require('ppt-png');

  render() {
    return (
      <div>
        <input
          type="file"
          ref={ref => this.fileFront = ref}
          accept=".png,.jpg,.jpeg,.ppt"
          name="frontdoc"
          onChange={this.handleConvertingfunction} />
      </div>
    );
  }
}
  handleConvertingfunction = (event) => {
    let files = event.target.files[0];
    let mfiles = [];
    mfiles.push(files);
    new Converter({
      files: [mfiles],
      output: 'output/',
      invert: true,
      callback: function (data) {
        console.log(data.failed, data.success, data.files, data.time);
      }
    }).run();
  }

but not getting any kind of log or detail or error.

w3nl commented 5 years ago

What framework are you using?

I have only test it just in pure Node.js, where files is an array of local files. (not uploaded to a temp dir) So if you show the mfiles, (with e.g. console.log), it can be a path or object with originalname and path. https://github.com/w3nl/ppt-png/blob/master/js/convert.js#L193

If you would see more details in the log, you can also change the logLevel to 4.

pankajDevFrontend commented 5 years ago

What framework are you using?

I have only test it just in pure Node.js, where files is an array of local files. (not uploaded to a temp dir) So if you show the mfiles, (with e.g. console.log), it can be a path or object with originalname and path. https://github.com/w3nl/ppt-png/blob/master/js/convert.js#L193

If you would see more details in the log, you can also change the logLevel to 4.

@w3nl i am using React Js.

pankajDevFrontend commented 5 years ago

Hello @w3nl now i have tried with node js and getting following error can you help me about this error and i am using mac mojave os 10.14.1

[
  {
    file: '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt',
    failure: 'Document convert',
    error: {
      Error: Commandfailed: libreoffice--headless--convert-topdf--outdiroutput/'/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'/bin/sh: libreoffice: commandnotfoundatChildProcess.exithandler(child_process.js: 297: 12)atChildProcess.emit(events.js: 197: 13)atmaybeClose(internal/child_process.js: 988: 16)atProcess.ChildProcess._handle.onexit(internal/child_process.js: 265: 5)killed: false,
      code: 127,
      signal: null,
      cmd: "libreoffice --headless --convert-to pdf --outdir output/ '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'"
    }
  }
][

][
  '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'
]5[
  {
    file: '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt',
    failure: 'Document convert',
    error: {
      Error: Commandfailed: libreoffice--headless--convert-topdf--outdiroutput/'/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'/bin/sh: libreoffice: commandnotfoundatChildProcess.exithandler(child_process.js: 297: 12)atChildProcess.emit(events.js: 197: 13)atmaybeClose(internal/child_process.js: 988: 16)atProcess.ChildProcess._handle.onexit(internal/child_process.js: 265: 5)killed: false,
      code: 127,
      signal: null,
      cmd: "libreoffice --headless --convert-to pdf --outdir output/ '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'"
    }
  }
][

][
  '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'
]
w3nl commented 5 years ago

Ok, the LibreOffice convert doesnt work. You can test this just with the LibreOffice command: libreoffice --headless --convert-to pdf --outdir output/ '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'

Is LibreOffice installed? And is your LibreOffice up-to-date?

You can also use another software to convert the document, see: Issue #2

pankajDevFrontend commented 5 years ago

Ok, the LibreOffice convert doesnt work. You can test this just with the LibreOffice command: libreoffice --headless --convert-to pdf --outdir output/ '/Volumes/Projects/REACTJS/my-app/src/assets/sample.ppt'

Is LibreOffice installed? And is your LibreOffice up-to-date?

You can also use another software to convert the document, see: Issue #2

yes libreOffice installed, need to create output directory like that ?

w3nl commented 5 years ago

In your code the output folder is output/. That is a relative path in your project. And yes, you have to create the folder output in your project.

But LibreOffice say: commandnotfoundatChildProcess ...

So it looks like LibreOffice is failing over the command.

Have you tried the LibreOffice command in your terminal?

pankajDevFrontend commented 5 years ago

In your code the output folder is output/. That is a relative path in your project. And yes, you have to create the folder output in your project.

But LibreOffice say: commandnotfoundatChildProcess ...

So it looks like LibreOffice is failing over the command.

Have you tried the LibreOffice command in your terminal?

can you share me or explain me command about terminal please ?

pankajDevFrontend commented 5 years ago

i have changed command libreoffice to other but this time i am getting new this error

Screenshot 2019-08-14 at 6 18 44 PM

w3nl commented 5 years ago

LibreOffice (or another alternative) should convert the spreadsheet (ppt/pptx/ods/...) to a pdf file. This pdf file should be stored in the output folder.

The pdf has for every slide a page. Than the pdf will be convert to images, every page will converted to an image. The package https://www.npmjs.com/package/pdf2image is used for this process. This package use Imagemagick for the convert progress. https://bitbucket.org/RicardoCacheira/pdf2image/src/e06968cef3dfa776e039a1b49931389831b71945/index.js#lines-297

I'll have to figure out why the pdf2image action doesnt work.

w3nl commented 5 years ago

I have made some changes, can you test it again with version 0.5.1?

pankajDevFrontend commented 5 years ago

LibreOffice (or another alternative) should convert the spreadsheet (ppt/pptx/ods/...) to a pdf file. This pdf file should be stored in the output folder.

The pdf has for every slide a page. Than the pdf will be convert to images, every page will converted to an image. The package https://www.npmjs.com/package/pdf2image is used for this process. This package use Imagemagick for the convert progress. https://bitbucket.org/RicardoCacheira/pdf2image/src/e06968cef3dfa776e039a1b49931389831b71945/index.js#lines-297

I'll have to figure out why the pdf2image action doesnt work.

ok let me check

pankajDevFrontend commented 5 years ago

Getting same error, please check attached screenshot.

image

w3nl commented 5 years ago

Has the output for write rights?

PieterWigboldus commented 5 years ago

With version 0.5.2 you receive more information about reading the pdf file. So if it is a write problem, you'll see it.

PieterWigboldus commented 5 years ago

Let me know if it works.

pankajDevFrontend commented 5 years ago

Let me know if it works.

yes, i have checked and still same issue.

pankajDevFrontend commented 5 years ago

Has the output for write rights?

Yes

PieterWigboldus commented 5 years ago

Do you have some information about: Operation system Node version ImageMagick version pdfinfo version

PieterWigboldus commented 5 years ago

@pankajDevFrontend Let me know if i can help you. If you send more details about your system, i can simulate the same situation.

pankajDevFrontend commented 5 years ago

Operation system . - Mac Mojave 10.14.1 (18B75) Node version . - v11.12.0 ImageMagick version - Version: ImageMagick 7.0.8-59 Q16 x86_64 2019-08-05 https://imagemagick.or pdfinfo version - Not able to get pdfinfo version

PieterWigboldus commented 5 years ago

If pdfinfo -v in your terminal doesnt work, you need to install the pdfinfo package. I dont have test the package in node 11, but i think i also works in node 11. You can try node 10 or 12, that are active node versions (https://github.com/nodejs/Release) I recommend nvm to switch between node versions: https://github.com/nvm-sh/nvm

w3nl commented 5 years ago

Can i close this issue @pankajDevFrontend ?