Comments (4)
@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.
@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.
@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.
Thanks @gregdolley! I'll see if this helps.
from node-pptx.
Related Issues (20)
- Extract presenter notes?
- Project status HOT 2
- Is it possible to center an image? HOT 1
- Is it possible to duplicate a slide?
- Is it possible to merge two pptx files? HOT 2
- Is there any way to get Slide from one pptx and add it to the current pptx?
- TypeScript definitions? HOT 4
- Would you accept a PR to allow loading pptx from buffer OR file path? HOT 2
- Is it possible to edit an existing Text Box? HOT 2
- Problems calling the library front next.js HOT 1
- is there any props to make text read only?
- Is it possible to save slides as images using node-pptx?
- Trying to integrate with this from my electron app with vue HOT 1
- Convert to Typescript HOT 3
- Allow passing an image name when adding to Slide
- Removing slide doesn't remove slides from [Content_Types].xml
- Make text bold
- Slide number shown by default change styling HOT 1
- npm package not updated? HOT 2
- issue
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 node-pptx.