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

New Report adding to previously created report #170

Closed
kammetherell opened this issue Sep 5, 2017 · 1 comment
Closed

New Report adding to previously created report #170

kammetherell opened this issue Sep 5, 2017 · 1 comment
Assignees

Comments

@kammetherell
Copy link

I'm trying to create a PPT file using NodeJS, currently everytime I click the button on my page to generate the report, it just appends it to the previous output.

I'm calling var pptx = require("pptxgenjs") everytime, as per the instructions, so not sure what I'm doing wrong. Apologies I'm a bit of a newbie to this.

My Route that generates the report is

router.get("/", function(req,res) {     //middlewareObj.isLoggedIn, 
    Plan.findById(req.params.id).populate("planEntries").exec(function(err,foundPlan){   
        if(err){
            console.log(err);
        } else {
            var pptx = require("pptxgenjs");
                      
            // Define Slide Layout
            pptx.setLayout('LAYOUT_16x9');
            
            // Cover Slide
            var slide = pptx.addNewSlide();
                slide.color = '575756';
                slide.slideNumber({ x:0.5, y:'90%', font_size:8, font_face:'Arial', color: 'fff'})
                
                slide.addImage({
                    path: './public/images/SlideCover.png',
                    x:0, y:0, w: '100%', h: '100%'
                });
                
                slide.addText(foundPlan.name, { x:0.4, y:1.5, font_size:36, font_face:'Arial', color: '26478d'});
                slide.addText('Contributing Region: ' + foundPlan.contributingRegion + '; Start Year: ' + foundPlan.startYear, { x:0.4, y:2.2, font_size:12, font_face:'Arial'});
                
            // Slide 1
            var slide = pptx.addNewSlide();
                slide.color = '575756';
                slide.slideNumber({ x:0.5, y:'90%', font_size:8, font_face:'Arial', color: 'fff'})
                
            // Slide 2
            var slide = pptx.addNewSlide();
                slide.color = '575756';
                slide.slideNumber({ x:0.5, y:'90%', font_size:8, font_face:'Arial', color: 'fff'})
                
            // Save PPT
            pptx.save("http", function(data){
                var strFilename = foundPlan.name+".pptx";
                res.writeHead(200, { 'Content-disposition':'attachment;filename='+strFilename, 'Content-Length':data.length });
		        res.end(new Buffer(data, 'binary'));
            });
        }
    });
});
@gitbrent
Copy link
Owner

gitbrent commented Sep 6, 2017

Hi @kamdickens ,

Thanks for the question.

See Issue #83 for an updated discussion of this very topic. Let me know what if anything works for you and i'll get the README updated.

@gitbrent gitbrent self-assigned this Sep 6, 2017
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

2 participants