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

Trouble running in NW.js #19

Closed
ghost opened this issue Dec 28, 2016 · 6 comments
Closed

Trouble running in NW.js #19

ghost opened this issue Dec 28, 2016 · 6 comments
Assignees

Comments

@ghost
Copy link

ghost commented Dec 28, 2016

I am trying to run PptcGenJS in a NW.js app. I used npm to installed PptcGenJS in my app/node_modules directory. I am using this code:

var pptxgenjs = require('pptxgenjs');

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();
slide.addText('Hello World!', { x:1.5, y:1.5, font_size:18, color:'363636' });
pptx.save('Sample Presentation');

I get no result. I'm guessing I'm not calling PptxGenJS correctly

@gitbrent
Copy link
Owner

gitbrent commented Dec 28, 2016

Hi Greg,

I've not tested or used NW.js, so i'm glad you picked an easy test case. :-)

  • Is there any output at all in the console or whatever debugging tools NW.js has?
  • Is requiring pptxgenjs enough to ensure that JSZip, FileSaver and jQuery are loaded as well?

@gitbrent gitbrent self-assigned this Dec 28, 2016
@ghost
Copy link
Author

ghost commented Dec 29, 2016

Hi Brent,

A little background: I'm making a desktop app that builds a PowerPoint presentation by reading embedded metadata (creator, title, caption, etc.) and inserting it in the slide beside the image. One problem I was having with officegen was aligning text vertically. I was happy to find PptxGenJS which has a valign attribute.

To answer your questions:

  • There is nothing in the console, and the NW.js dev tool shows no errors.
  • The way I'm requiring pptxgenjs might be the problem, but I'm not sure. I'm still learning NW.js and trying to understand how modules work. It looks like the package.json file correctly specifies the location of the main file as "dist/pptxgen.js" and it includes the dependencies: "file-saver": "^1.3.2", "jquery": "^3.1.0", "jszip": "^3.1.2"
    It might be the way I'm running pptxgenjs. I need to do more research on this.

I have had success running officegen by using:

var officegen = require('officegen');

var pptx = officegen ( 'pptx' )
slide = pptx.makeNewSlide ();
slide.addText ( 'This is a test' );
var out = fs.createWriteStream ( 'out.pptx' );
pptx.generate ( out );

@gitbrent
Copy link
Owner

Hi Greg,

That's a really cool project idea. Once we determine what's needed to get NW.js stood up, i'll update the documentation to help others going forward.

Lack of errors or output sure sounds like we're not even getting off the ground.

Try to get the version from the console: new PptxGenJS().getVersion()
I get "1.1.3" - I suspect you'll get "Uncaught ReferenceError: PptxGenJS is not defined"

If so, then you're on the right track with the package requirements being the issue.

gitbrent pushed a commit that referenced this issue Jan 17, 2017
Fixed Issue #19 and Issue #23.
@gitbrent gitbrent reopened this Jan 17, 2017
@ghost
Copy link
Author

ghost commented Jan 17, 2017 via email

@gitbrent
Copy link
Owner

Yeah, wouldn't you know it. My initial testing was great, then after I updated the issue and tried with the NPM release it tanked.

I'm working out all the remaining issues now and hope to have it done within a day or so...

Sorry for jumping the gun!

gitbrent pushed a commit that referenced this issue Jan 18, 2017
Resolves Issue #19 and Issue #23.
gitbrent pushed a commit that referenced this issue Jan 18, 2017
Fixes for Issue #19 and Issue #23.
@gitbrent
Copy link
Owner

Hi Greg,

Version 1.1.5 has resolved this issue. I'm embarrassed to admit this is all my fault - Node.js functionality has been defunct for some time and it's not something i've tested with in while and... ugh.

It's running for me in Node.js (4.x) using npm v1.1.5-1 now and i've updated the Readme with integration details:

var pptx = require("pptxgenjs");

I've also created a Node.js test script under ./examples that can be run using node nodejs-demo.js

Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant