Giter VIP home page Giter VIP logo

Comments (23)

Ziv-Barber avatar Ziv-Barber commented on July 20, 2024

Thanks for the samples, I'll try to find out what's wrong with it.

Ziv

On Tue, Jan 28, 2014 at 2:48 AM, Eugene Ware [email protected]:

Hi, absolutely LOVE officegen. We'd love to use it to generate powerpoint
slides in a new project that we're building.

However, there's a problem with the file format generated by pptx.

When I generate out the example pptx in the examples folder (or even just
a basic single slide - see code below), and try to open it in the latest
Keynote on Mac OS X I get the error:

"bad.pptx" can't be opened.

Ideally, rather than generate both keynote and pptx files, we could just
generate a single pptx file and rely on keynote compatibility to work with
both.

Here's the bad.pptxhttps://dl.dropboxusercontent.com/u/4763380/officegen/bad.pptxthat is generated that causes the issue.

When I open the bad.pptx in MS Powerpoint and save it back out as
good.pptx here's what I get:

good.pttxhttps://dl.dropboxusercontent.com/u/4763380/officegen/good.pptx

Here's the test js file that creates the bad.pptx:

var officegen = require('officegen');
var fs = require('fs');var path = require('path');
var pptx = officegen ( 'pptx' );
var slide;var pObj;
pptx.on ( 'finalize', function ( written ) {
console.log ( 'Finish to create a PowerPoint file.\nTotal bytes created: ' + written + '\n' );
});
pptx.on ( 'error', function ( err ) {
console.log ( err );
});
pptx.setDocTitle ( 'Sample PPTX Document' );
// Let's create a new slide:slide = pptx.makeNewSlide ();
slide.name = 'The first slide!';
// Change the background color:slide.back = '000000';
// Declare the default color to use on this slide:slide.color = 'ffffff';
// Basic way to add text string:slide.addText ( 'Created using Officegen version ' + officegen.version );slide.addText ( 'Fast position', 0, 20 );slide.addText ( 'Full line', 0, 40, '100%', 20 );
var out = fs.createWriteStream ( 'bad.pptx' );
out.on ( 'error', function ( err ) {
console.log ( err );});
pptx.generate ( out );

Reply to this email directly or view it on GitHubhttps://github.com//issues/18
.

from officegen.

eugeneware avatar eugeneware commented on July 20, 2024

Thanks @Ziv-Barber!

from officegen.

spollack avatar spollack commented on July 20, 2024

We've seen this issue too -- would be great to get it working with Keynote. thanks!

from officegen.

timlesallen avatar timlesallen commented on July 20, 2024

Best of luck @Ziv-Barber!

from officegen.

StefanVanDyck avatar StefanVanDyck commented on July 20, 2024

I think I may have had the same problem.
I'm assuming you're trying generate a powerpoint into a HTTP-response.

My problem was caused by the asynchronous nature of node. The HTTP-stream closed before the officegen generate function terminated. The fix i used was using futures to wait for the generate function to finish and only then closing the http response.

from officegen.

fsad avatar fsad commented on July 20, 2024

@stefanvd: This is exactly what I am trying to do right now. Do you have any sample code for your solution? I am using express.
Thanks!

from officegen.

StefanVanDyck avatar StefanVanDyck commented on July 20, 2024

I'm using meteor so I'm not really sure how it maps to other platforms.
Also I don't know if this kind of asynch behaviour holds for normal node operations.

A solution would look like this, note the use of futures.

var Future = require('fibers/future');
var fut = new Future();

var officegen = require('officegen');

var fs = require('fs');
var path = require('path');

var pptx = officegen ( 'pptx' );

var slide;
var pObj;

pptx.on ( 'finalize', function ( written ) {
            console.log ( 'Finish to create a PowerPoint file.\nTotal bytes created: ' + written + '\n' );

            fut.return();

        });

pptx.on ( 'error', function ( err ) {
            console.log ( err );

            fut.return();

        });

pptx.setDocTitle ( 'Sample PPTX Document' );

// Let's create a new slide:
slide = pptx.makeNewSlide ();

slide.name = 'The first slide!';

// Change the background color:
slide.back = '000000';

// Declare the default color to use on this slide:
slide.color = 'ffffff';

// Basic way to add text string:
slide.addText ( 'Created using Officegen version ' + officegen.version );
slide.addText ( 'Fast position', 0, 20 );
slide.addText ( 'Full line', 0, 40, '100%', 20 );

var out = fs.createWriteStream ( 'bad.pptx' );

out.on ( 'error', function ( err ) {
    console.log ( err );
});

pptx.generate ( out );

fut.wait();

from officegen.

fsad avatar fsad commented on July 20, 2024

Thanks, I will have a try!

from officegen.

StefanVanDyck avatar StefanVanDyck commented on July 20, 2024

I just saw I made a mistake in simply copy/pasting the previous code. In case of HTTP-response there shouldn't be a

var out = fs.createWriteStream ( 'bad.pptx' );

out.on ( 'error', function ( err ) {
    console.log ( err );
});

pptx.generate ( out );

But rather

pptx.generate(this.response)

from officegen.

spollack avatar spollack commented on July 20, 2024

@Ziv-Barber any news on a solution to this? thanks!

from officegen.

dgerrity avatar dgerrity commented on July 20, 2024

We're experiencing the same Keynote problem.

from officegen.

Ziv-Barber avatar Ziv-Barber commented on July 20, 2024

I'm working on that. I'll let you know.
Sorry about the delay :(

On Wed, Aug 20, 2014 at 1:24 AM, Dan Gerrity [email protected]
wrote:

We're experiencing the same Keynote problem.


Reply to this email directly or view it on GitHub
#18 (comment).

from officegen.

eugeneware avatar eugeneware commented on July 20, 2024

Don't apologize @Ziv-Barber - this is a great library. Keep up the great work!

from officegen.

keithmo avatar keithmo commented on July 20, 2024

I have a fix for this issue; it's a relatively simple change in genpptx.js. #51

from officegen.

mlolson avatar mlolson commented on July 20, 2024

Keynote crashes when I try to open the pptx generated by the example script. The pptx appears to convert successfully then keynote crashes before opening the file.

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

I seem to experience this issue as well running officegen 2.14.0 and Keynote 6.5.3. If there's any way I can help, providing logs etc. let me know.

from officegen.

pietersv avatar pietersv commented on July 20, 2024

@dasblitz @mlolson

  • Is the issue unique to Keynote? Can you open the file without issue in PowerPoint and/or LibreOffice?
  • Can the issue be localized to specific content, or does even the smallest file crash in Keynote? If a minimal file works, can you isolate the problem content?
  • If the file opens fine in PowerPoint but crashes Keynote, can you save it to a new file from within PowerPoint and open the new saved file within Keynote? (not suggesting that your workflow in production be to open/resave each file manually, these are just diagnostic questions...)

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

I just downloaded Open Office and the generated pptx works. I've minimized the code to the code below basically creating an empty pptx. The generated pptx file opens in Open Office but Keynote immediately shows 'Can't open file'. If I save the file from Open Office to a .ppt file the ppt file opens in Keynote.

var pptx = officegen ( 'pptx' );
pptx.on ( 'finalize', function ( written ) {
    // ... 
    console.log ( 'Finish to create the surprise PowerPoint stream and send it to ' + response.post.name + '.\nTotal bytes created: ' + written + '\n' );
});

pptx.on ( 'error', function ( err ) {
    // ...
    console.log ( err );
});

pptx.generate ( response );

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

To add, open office has no option for saving to .pptx just ppt. I''l have to wait until monday before I have access to a macbook with powerpoint installed.

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

So I just downloaded LibreOffice as well. Turns out that if I create a new slideshow in Libre Office and save it as a .pptx weather it's the Microsoft PowerPoint 2007-2013 XML (.pptx) or the Open Office XML Presentation (.pptx) both of them won't open in Keynote ("file.pptx can't be opened").

If I create a pptx file from Keynote and unzip the file to view the xml. The [Content_Types].xml differs quite a lot from the [Content_Types].xml that officegen generates:

https://www.dropbox.com/s/tf3hlio1lwzq1m0/diff.jpg?dl=0

So it seems this is more a Keynote problem than an officegen 'bug'.

from officegen.

pietersv avatar pietersv commented on July 20, 2024

Awesome sleuthing. Concur it's probably specific to Keynote. I've been surprised by how brittle PowerPoint and Keynote are to even the slightest deviation from expected content.

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

@pietersv @Ziv-Barber

Well this was bugging me so I dug a little deeper. The problem seems to come from the generated file

ppt/_rels/presentation.xml.res

Compared to a pptx generated with MS Powerpoint. It's missing the presProps, viewProps, theme1 and tableStyles relationship definitions.

The pptx seems to open in Keynote if I replace the codeblock in genpptx.js at line 1164 with the following:

gen_private.type.msoffice.rels_app.push (
    {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
        target: 'slideMasters/slideMaster1.xml',
        clear: 'type'
    }, {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide',
        target: 'slides/slide1.xml'
    }, {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps',
        target: 'presProps.xml'
    } , {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps',
        target: 'viewProps.xml'
    }, {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
        target: 'theme/theme1.xml'
    }, {
        type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles',
        target: 'tableStyles.xml'
    }
);

Note that the order of slideMaster1 and slide1 is important. If you put the slide1 object in the end it doesn't work.

I can make a pull request for this, but it feels a little hacky due to me semi-understanding the whole pptx thing, so I'm not sure weather this could break anything.

from officegen.

dasblitz avatar dasblitz commented on July 20, 2024

Fuck me, I just forked the repository and saw the code on git already had this fixed. Now I also see @keithmo had a similar fix. I never looked in to it because it seemed it was fixed so I figured this was a new problem. It's just that the npm module still has the old code. Well at least now I know something more about pptx.

from officegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.