Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pankajDevFrontend opened this issue Aug 13, 2019 · 29 comments
Closed

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

pankajDevFrontend opened this issue Aug 13, 2019 · 29 comments
Assignees
Labels
bug configure A configuration wasnt good

Comments

@pankajDevFrontend
Copy link

pankajDevFrontend commented Aug 13, 2019

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
Copy link
Owner

w3nl commented Aug 13, 2019

Is in your code files an array?

@pankajDevFrontend
Copy link
Author

Is in your code files an array?

nope, it's just single file.

@w3nl
Copy link
Owner

w3nl commented Aug 13, 2019

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
Copy link
Author

th the single file.

ok let me check with this solution.

@w3nl w3nl self-assigned this Aug 13, 2019
@pankajDevFrontend
Copy link
Author

pankajDevFrontend commented Aug 13, 2019

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
Copy link
Owner

w3nl commented Aug 13, 2019

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
Copy link
Author

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
Copy link
Owner

w3nl commented Aug 13, 2019

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

w3nl commented Aug 14, 2019

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
Copy link
Author

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
Copy link
Owner

w3nl commented Aug 14, 2019

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

w3nl commented Aug 14, 2019

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
Copy link
Owner

w3nl commented Aug 14, 2019

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

@pankajDevFrontend
Copy link
Author

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
Copy link
Author

Getting same error, please check attached screenshot.

image

@w3nl
Copy link
Owner

w3nl commented Aug 16, 2019

Has the output for write rights?

@PieterWigboldus
Copy link
Collaborator

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 PieterWigboldus added bug configure A configuration wasnt good labels Aug 16, 2019
@PieterWigboldus
Copy link
Collaborator

Let me know if it works.

@pankajDevFrontend
Copy link
Author

Let me know if it works.

yes, i have checked and still same issue.

@pankajDevFrontend
Copy link
Author

Has the output for write rights?

Yes

@PieterWigboldus
Copy link
Collaborator

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

@PieterWigboldus
Copy link
Collaborator

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

@pankajDevFrontend
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Owner

w3nl commented Oct 14, 2019

Can i close this issue @pankajDevFrontend ?

@w3nl w3nl closed this as completed Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug configure A configuration wasnt good
Projects
None yet
Development

No branches or pull requests

3 participants