-
Notifications
You must be signed in to change notification settings - Fork 664
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
Integration to the Angular 4 #220
Comments
Hi @darsana , If Angular is like Node, then you dont need the First, try just this: Then see if removing the new line works: generatePPT() {
var slide = pptx.addNewSlide();
var opts = { x: 1.0, y: 1.0, font_size: 42, color: '00FF00' };
slide.addText('Hello World!', opts);
pptx.save();
} |
Thank you for the response. I tried as you mentioned The version of the pptx is 1.9.0.20171010 And my Node version is 3.10.10 Now I am getting the error like below core.es5.js:1020 ERROR Error: Uncaught (in promise): TypeError: fs.writeFile is not a function |
Ah, Angular is being detected as Node and is trying use the Node Does anything discussed in Issue 72 help? |
I did below 2 changes in library and able to use the library with Angular4
//module.exports = new PptxGenJS();
module.exports = PptxGenJS;
else /*if ( NODEJS ) {
if ( gObjPptx.saveCallback ) {
if ( strExportName.indexOf('http') == 0 ) {
zip.generateAsync({type:'nodebuffer'}).then(function(content){ gObjPptx.saveCallback(content); });
}
else {
zip.generateAsync({type:'nodebuffer'}).then(function(content){ fs.writeFile(strExportName, content, gObjPptx.saveCallback(strExportName)); });
}
}
else {
zip.generateAsync({type:'nodebuffer'}).then(function(content){ fs.writeFile(strExportName, content); });
}
}
else {*/
zip.generateAsync({type:'blob'}).then(function(content){ writeFileToBrowser(strExportName, content); });
//}
}) After doing these 2 fixed I am able to integrate with my Angular 4. |
Thanks for the follow-up @mayurjhanwar ! Issue #83 will change the export to a factory/constructor (target 2.0). |
Hi Brent, |
@vasanthBR same here, do you find any solution? |
Update: Oct-2018: Latest Issues: |
Use PPtxGenJs in angular2+ like this:
|
------------------------------------------Add Index.html file-------------------------------------- <script src="https://cdn.rawgit.com/gitbrent/PptxGenJS/8cb0150f/dist/pptxgen.bundle.js"></script>Move to component and added --------------------------------- App.component.ts --------------------------------------------------------- import { Component } from '@angular/core'; declare var PptxGenJS: any; constructor() { Note : Js file do not know the function name so we have to declare function name in component example i have use in my compionent |
I have this working in several Angular applications. Here are the steps to use it in an Angular 6+ app: The primary assumption is that you have an existing Angular project generated with Angular-CLI (the only sane way to work with Angular!), and you want to be able to generate and download slide decks for your client.
( otherwise you'll get this error:
|
Tried the Ppt generation into the angular 4 project by installing through node js like below
npm install pptxgenjs
var pptx = require("pptxgenjs");
but call to the ppt generation function not giving any response
generatePPT() {
var pptx = new pptx();
var slide = pptx.addNewSlide();
var opts = { x: 1.0, y: 1.0, font_size: 42, color: '00FF00' };
slide.addText('Hello World!', opts);
pptx.save();
}
The text was updated successfully, but these errors were encountered: