Code Monkey home page Code Monkey logo

Comments (4)

gregdolley avatar gregdolley commented on July 21, 2024

@rajatkhare619 - What kind of tables are you talking about? Like an Excel type table of tabular data, or something else?

Regarding your PptxGenJS integration question: your code example definitely won't work because the "slide" object of PttxGenJS is compleely different from the one in nodejs-pptx. In PptxGenJS, their slide object contains properties and data structures that completely describe all the elements of a slide along with their position, size, color, text (if applicable), etc. This data is then used by the "save" function to generate "Office OpenXML/PresentationML" XML for each slide, which is then zipped up and saved to disk with the "pptx" extension (OK, this is an oversimplification, but you get the idea).

In contrast, in nodejs-pptx, the slide object already contains the OpenXML data describing the slide, which is eventually written to disk when you call save. There is no "second-pass" of converting the slide description to XML like you have in PptxGenJS. The OpenXML data contained in each slide object of nodejs-pptx is dynamically changed as you manipulate the pptx content via API calls.

So, that being said, if you were able to get the post-generated OpenXML data for a slide in PptxGenJS, and then you were to transfer it to a nodejs-pptx slide object, then yes, in theory, you could use PptxGenJS to create a slide and add it to nodejs-pptx.

Note however, that if the pptx in PptxGenJS was just slightly structurally different than the one in nodejs-pptx (like containing a different number of slides, different number of images, etc.), then the internal "RId's" of certain reference objects in the PptxGenJS slide XML will no longer be valid (or point to the wrong data) when used in the nodejs-pptx generated deck.

You would need to write some code to update/fix these ID values before generating the final pptx XML.

from node-pptx.

rajatkhare619 avatar rajatkhare619 commented on July 21, 2024

@gregdolley Thanks for the explanation.
I was talking about these types of tables (Excel like sounds good):
https://gitbrent.github.io/PptxGenJS/docs/api-tables.html
I thought it would be easier to add text in tables which would automatically create new slides in case the table rows overflow the current slide.

I don't know if there is a way to find remaining space and currently occupied space by text with node-pptx. That would be useful.

from node-pptx.

gregdolley avatar gregdolley commented on July 21, 2024

@rajatkhare619 - Ah OK, I know the tables you're talking about. Unfortunately, our nodejs-pptx API doesn't support these kinds of tables yet.

But for your second issue of finding the amount of remaining space vertically, and therefore, knowing when to page-break -- you could probably literally calculate it from the font size, font-type, and line spacing. Given any font type, the vertical size of each character is consistent for the font size being used - so point 12 font size means the vertical dimension of the character's bounding box will be 12 points high. Line spacing is obviously consistent as well. Add those two values - we'll call it "line_height." Convert points to pixels, and calculate the number of vertical pixels of each slide (use the PptxUnitHelper class for that) and you could just do slide_pixel_height/line_height = max # of lines per slide. Ex:

let num_lines_per_slide = PptxUnitHelper.toPixels(PptxUnitHelper.fromInches(slide_height_in_inches))/line_height;

I hope this helps as a work-around.

from node-pptx.

rajatkhare619 avatar rajatkhare619 commented on July 21, 2024

Thanks @gregdolley! I'll see if this helps.

from node-pptx.

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.