Giter VIP home page Giter VIP logo

officegen's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

officegen's Issues

Support for italicized text in pptx files

sample options:

slide.addText ( 'Boom!!!', {
    y: 250, x: 10, cx: '70%', 
    font_face: 'Wide Latin', font_size: 54, 
    color: 'cc0000', bold: true, underline: true, italic: true } );

Version Bump?

Hi, You've made updates but have not done a version bump so the npm package manager installs the old version. Can you update the package.json etc.?

addImage() for docx?

Hey, first off, this is a nice module!

I was almost able to use it for a current project, but your docx generation doesn't support inserting images into a docx file..

Is it a feature you will eventually get to? I see that the pptx generation supports it, so I thought I'd ask...

Read Office files?

I realize this is a bit of a stretch from this library, but I'm looking for ways to read Office files with JavaScript (server or client-side). Any plans to add that here, or suggestions on where to look?

support streams or buffers

Would it be possible to extend support in slide.addImage() and pptx.generate() to simplify generating slidedecks on a server from in-memory data?

Now what I do is:

  • given a base64 image, I remove the metadata (data:image/png;base64,), then convert it to a Buffer, save it as a file using node-temp, then pass that file to slide.addImage()
  • given the assembled slidedeck, I create a tmp file to generate the pptx, then read it to a buffer to serve in an express middleware

Not sure if streams or buffers would be better here, I guess either one is fine as long as I don't need to bother with temp files.

Documentation for available object properties missing.

It would be great to have a comprehensive list (or a link to an outside resource) for a list of available object properties. For example, working on pptx I was unable to find all available properties of the slide.addShape() method such as 'ellipse' or 'shape: "roundRect"' or how to draw a border. Thank you!

disable/override setting Author, Company document properties

officegen currently sets these two document properties to "officegen". I'd like to not set these properties at all (or set them to my own string). What is the best way to do that?

I see the method .setDocTitle() that allows me to set the Title property, but i didn't see methods for other properties.

Thanks,
Seth

Insert image in xlsx.

I am finding a way to insert an image to a n xlsx cell. Is there a way to do it? I am unable to find a proper way to do it with this module.

XLSX Date support

Using the two dimensional array, dates are written as zero values:

var fs = require('fs');
var officegen = require('officegen');
var xlsx = officegen ( 'xlsx' );

xlsx.on ( 'finalize', function ( written ) {
            console.log ( 'Finish to create an Excel file.\nTotal bytes created: ' + written + '\n' );
        });

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

sheet = xlsx.makeNewSheet ();
sheet.name = 'Excel Test';

// The direct option - two-dimensional array:
sheet.data[0] = [];
sheet.data[0][0] = new Date();

var out = fs.createWriteStream ( 'out.xlsx' );

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

xlsx.generate ( out );

The addImage method example is with wrong paramter

pObj.addImage ( path.resolve(__dirname, 'myFile.png' ) );
pObj.addImage ( path.resolve(__dirname, 'myFile.png', { cx: 300, cy: 200 } ) );

It should be :
pObj.addImage ( path.resolve(__dirname, 'myFile.png' ), { cx: 300, cy: 200 } );

officegen calling finalize event before document is flushed to disk

We are seeing consistent behavior where when officegen raises the finalize event, the file is not yet flushed to disk. For example, the finalize event will say the pptx is 745239 bytes, but if i do fs.stat on the file immediately afterwards, the size is 741962. a few milliseconds later, the file size is as expected. This is using officegen 0.2.8 on node 0.10.28. We do not see this behavior (or at least not consistently) on node 0.8.26.

our generation code looks like this:

            var out = fs.createWriteStream(paths.pptxFilePath);
            out.on('error', function (error) {
                onCompletion(error, null);
            });

            pptx.generate(out, {
                error: function (error) {
                    onCompletion(error, null);
                },
                finalize: function (bytesWritten) {
                    onCompletion(null, bytesWritten);
                }
            });

Do we need to do something different to know when it is available on disk? For now, i'm calling fs.stat in a loop with a small delay until the file sizes match (uggh).

Documentation does not cover bodyProp options (i.e. vertical text alignment)

Please see https://github.com/Ziv-Barber/officegen/blob/master/lib/genpptx.js#L635-L678

Corresponding example:

function addSlides(lyrics) {
  var slides = lyrics.split('\n\n');
  console.log(slides.length + ' slides to generate');
  console.log(slides);

  for (var i in slides) {

    var lyrics = slides[i].split('\n').join('\r'); // Microsoft :/
    var lines = lyrics.split('\r').length;

    slide = pptx.makeNewSlide();
    slide.back = { type: 'solid', color: 'ffffff' };

    pObj = slide.addText(lyrics, {
      x: 0,
      y: 0,
      cx: '100%',
      cy: '100%',
      fill: 'ffffff',
      font_size: fontSize,
      align: 'ctr',
      color: {
        type: 'solid',
        color: '000000'
      },

      bodyProp: {
        anchor: 'ctr', // vertical align text
      },
    });

    pObj.options.align = 'center';
  }
}

how do I do a line break (ie: <br>) instead of a new paragraph (ie: <p>)

Hi there. I LOVE your library. It's so useful. Thank you so much for making it.

So, I'm trying to figure out how to do a single line break instead of the double line break that appears with each new paragraph (ie: pObj).

In HTML speak, it would be nice to be able to do a
instead of a

.

Docx Templates/Content Replace

Hi,

This module looks great, I've had a browse through but not found anything. I'm looking to import a doc/docx file and replace conbtent with new content e.g '{{title}}' with 'My New Title'. Much like handlebars or other templating engines.

Is this possible with your module?

Cheers,
Ben.

font size is divided in half

Again, love the plugin. I noticed that if I used font_size 20, the font in word will actually end up being font size 10. Same for 40, it becomes 20 in word.

XLSX with cells containing newlines

Hi,

I want to set a cell to a text that contains newline characters. So I have a cell with the value set to 'X\nY' or 'X\r\n\Y' that I want to be shown as two lines when in Excel, but instead it shows as 'X Y' on the same line.

Any idea why this happens and how I can work around it?

Edit text in a slide

Can we have the option of editing text in a slide?

And centering text is not working as expected.

Add image from url

Would be nice to be able to add images from url. Is that possible?

pObj.addImage('http://mycdn.com/logo.png')

Officegen 0.2.7 never finalizes in Node 0.8

OfficeGen prompts the user to start downloading the file as soon as docx.generate(res) is hit, however, it never finishes creating the file. In fact, it never even hits the callback of the finalize event (as shown below). Which makes me wonder... why does OfficeGen prompt the user before the file is built? And can we circumvent that by not sending anything to the user until the file is built?

var docx = officegen('docx');
// Here I call docx.createP().addText("foo bar") about 300 times
docx.on ( 'finalize', function () {
            console.log('This console log is never being written out.');
});
docx.on ( 'error', function ( err ) {    
            console.log ( err );
});
docx.generate(res);

Set Cell Background in XLSX

How do I set the background of a cell in an xlsx document? If this isn't possible, do you know what I should look at to begin implementing that. I'd be happy to submit a pull request if you like.

Unreadable Content

After generating a Word Doc I get the following errors when trying to open it.

screen shot 2015-07-24 at 11 37 28 am

screen shot 2015-07-24 at 11 38 07 am

This is a very simple document with a single word in it. Do you have any idea what could be causing this?

Thanks for word.addImage()! Any chance of word.addTable() / addHTML() ?

Hi Ziv,

I'm already implementing the addimage feature for the system we're using, so thanks!

The ability to add either a table or an HTML fragment containing an HTML table would be amazingly useful to us! Any chance you feel generous enough to implement it?

Thanks again for the addImage() method!

Creating charts requires Java

I kept getting mysterious errors trying to generate charts with the new addChart() command. After digging into it for a while I discovered it was because I didn't have Java installed. This is because line 865 of lib/msexcel- builder runs the jar command via shell/exec. If jar is not an available command then you get an ENOENT error because it never creates sample1.xlsx and thus can't read the file.

This is either an unnecessary dependency, or it's a documentation issue. I wasn't sure which so I didn't make a pull request and instead am filing this bug. Anyway, thanks for an overall great library!

Creating bullet lists

The createListOfDots and CreateListOfNumbers doesn't really do anything for me. I assume it's supposed to make bullet-point formatting, but even when I create the sample doc, it just appears as new lines (no bullets or numbers). Is this a well-known problem? Is there a different way to create bullet points?

Attached is the bottom of the sample doc. Is that how it's supposed to look?
screenshot from 2014-11-03 13 09 10

How to add a bar chart

How do I add a bar chart? The documentation is very inconsistent, it doesn't look like it's possible to add a barchart w/ the example code, is this correct? `slide.addBarChart(
{ title: 'Sample bar chart',
data: [ // each item is one serie
{
name: 'europe',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.5, 2.6, 2.8],
color: 'ff0000' // optional
},
{
name: 'namerica',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.5, 2.7, 2.9],
color: '00ff00' // optional
},
{
name: 'asia',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.1, 2.2, 2.4],
color: '0000ff' // optional
},
{
name: 'lamerica',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.3, 0.3, 0.3],
color: 'ffff00' // optional
},
{
name: 'meast',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.2, 0.3, 0.3],
color: 'ff00ff' // optional
},
{
name: 'africa',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.1, 0.1, 0.1],
color: '00ffff' // optional
}

]
}

);`

support for tabstops or tables docx

There is no way to add tables / configure tabstops in docx files. This would be useful when trying to layout content in a tabular/presentable manner.

Would this be possible to add into the officegen API?

feature request: callback to generate()

Right now i have to listen on the finalize event to know when a pptx has been written out. it would be great to be able to pass a callback instead to generate. The reason is that i'm writing using streamline (https://github.com/Sage/streamlinejs) and it doesn't mesh well with event emitters. I wrote a wrapper for now that listens for the events, and maps it into a callback.

Is it possible to and slides to an existing PPT document?

Hi, our client has an existing PPT template with lots of pre defined styles and layouts.

Is it possible to use this as the base for a our generated one? So the outputted ppt still has these styles and templates?

We don't need templating in the traditional sense (we make all the dynamic slides from scratch), we just want to keep / include the other styles and layouts into the final PPT.

m

generate never exits

Hi, I'm using Node 10.38.

When running my code on the dev box, pptx.generate works fine and the output file is generated.

However on my Ubuntu Server it never really exits. Any reason why this happens?

Compatibility: Latest Keynote won't open officegen generated pptx files

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.pptx that 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.pttx

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 );

The text without space will not appear in docx

In Node 10.28, and LibreOffice

Nothing appear in docx without space after the words.

var pObj = docx.createP();
pObj.addText('Hello,World');

but it works like

var pObj = docx.createP();
pObj.addText('Hello,World ');

Do I have to add space?

DOCX setting cx to percentage does not show image

DOCX
When adding an image, and attempting to set cx to a percentage, the image is not shown.

  • pObj.addImage( path.resolve(__dirname, 'file.jpg'), {cx: '45%'}); <--- not working

When adding an image, and setting cx to a number, the image is shown.

  • pObj.addImage( path.resolve(__dirname, 'orgHeader.jpg'), {cx: '600'}); <--- working

addImage for xlsx

Pretty straight forward really; it would be nice to insert and size an image into a cell

Returning doc,docx files's proprieties like number of pages

I want to know if it's possible to be made with officegen or do I need something else. I want to get all files from a folders and return how many pages has each document with names and everything. I need an quick answer so anything will do . Thank you for the support.

support for larger png images in pptx

I had no issues adding a smaller logo .png with slide.addImage(). However, I tried several larger .png images from different sources and they didn't render in the output. I see no errors on the server.

[BUG] putPageBreak() crashed in docxgen

if ( (objs_list[i].data[j].text[0] == ' ') || (objs_list[i].data[j].
                                     ^
TypeError: Cannot read property '0' of undefined

putPageBreak() makes the TypeError. The detail of the code as follows,

var docx = officegen({
'type': 'docx'
});

var pObj = docx.createP();
pObj.addText('Hello,World ');
docx.putPageBreak();

var out = fs.createWriteStream ('out.docx');
out.on('error', function (err) {
console.log(err);
});
docx.generate(out);

Node 0.10.28

latest archiver versions break pptx output in some cases

Officegen makes use of the archiver module. With the following module set (i.e. what you get from a default install of latest officegen right now), we get intermittent failures during pptx output. Specifically, we make the call to pptx.generate(), but it often hangs partway through, never emiting either the error or finalize events.

However, with achiver rolled back to 0.4.10, it works reliably. So it isn't an officegen issue per se.

The environment where we are testing and see issues with [email protected] is using node 0.8.26, running on linux (heroku dynos). Interestingly, the exact same code running on my OSX dev machine doesn't have this issue. Something subtle is happening here. It happens quite often with longer powerpoints; single slide ones seem to succeed.

We put in some logging within the officegen generate() code, and were able to see that it dies inside of archiver. The exact spot within the pptx export where it dies varies from run to run.

For now, we are working around this via an npm shrinkwrap file that locks us to the old [email protected].

The reason i'm raising the issue here is to warn officegen users, and to see if anyone else has anyone else hit this issue already, or can repro it.

I'd like to open a ticket with archiver, but i don't have a great repro case currently that doesn't involve a ton of other code.

Also, @Ziv-Barber you might want to lock officegen to archiver:~0.4.10 for now?

Support for headlines

Is there no support for Word headline/heading styles, or am I just missing something?

missing requires statement in genpptx.js

Just hit this, in genpptx.js, line 889.

node_modules/officegen/lib/genpptx.js:889
                    var image_ext = path.extname ( image_path );
                                    ^
ReferenceError: path is not defined

I hit this by trying to insert a pdf file just to see what would happen. is it possible to stick a pdf directly into an pptx document? or does it need to be converted to emf or similar first?

Cool library, thanks for sharing it.

Header / Footer

It would be great to build headers and footers into a word document. It looks like the xml syntax is the same if not restricted, except there's "header1.xml" and "footer1.xml" in addition to "document.xml". Thoughts?

XLSX with cell format

Dear Sir,

I'm interesting to this tool.
Do you have any plan to add "Cell formatting" function for XLSX file?

Best regards,

single instance images in pptx

If you insert the same image multiple times into a slide deck (say, an image you put once on each slide), you end up with N copies of that image in the pptx, instead of just one. This makes the file sizes larger. It would be great to store these in a single instance way.

published npm version 0.2.7 seems broken

When I do an npm install of the latest version (0.2.7) in npm and try to run any of the examples, they just exit without writing out the full file properly.

When I use what's in master, using a:

  "dependencies": {
    "officegen": "git+https://github.com/Ziv-Barber/officegen.git"
  },

It works fine.

Has master been published to npm?

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.