Comments (23)
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.
Thanks @Ziv-Barber!
from officegen.
We've seen this issue too -- would be great to get it working with Keynote. thanks!
from officegen.
Best of luck @Ziv-Barber!
from officegen.
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.
@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.
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.
Thanks, I will have a try!
from officegen.
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.
@Ziv-Barber any news on a solution to this? thanks!
from officegen.
We're experiencing the same Keynote problem.
from officegen.
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.
Don't apologize @Ziv-Barber - this is a great library. Keep up the great work!
from officegen.
I have a fix for this issue; it's a relatively simple change in genpptx.js. #51
from officegen.
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.
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.
- 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.
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.
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.
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.
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.
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.
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)
- how to set header and footer inside docx using officegen HOT 1
- How to make a particular page Orientation to A3 / Landscape ? HOT 2
- How to add Sections in word file with Officegen ? and how to set font size and to make it bold for entire column in a table
- How to set the first line indentation for a paragraph in word?
- Can i remove Header and Footer from First page ( Title Page ) and some more queries
- Why does the table fill color not work?
- Cannot generate word file in render process for one Electron app
- How to add repeat header in table docx
- How to insert image into tableceil in docx
- how to open a word document ?
- Is addImage with svg supported for pptx file?
- How to assign color property to newline in table cell in word document ?
- 如何将word转换html,html里面的style css可以转换?
- Embedded File is still being accessed by createReadStream asynchronously even after deletion in officegen for Word Document
- Make the generated document read-only of password protected?
- Can I set a password to access Word
- How to add Number Bullet lists and Sub Number Bullet list
- How can i set auto-warp attribute to a column or cell in Excel file?
- Suggestion:Footer supports inserting tables
- May I ask if it is possible to add a background color to the Word document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officegen.