Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Text Options do not apply #427

Closed
sunnyar opened this issue Oct 29, 2018 · 5 comments
Closed

Dynamic Text Options do not apply #427

sunnyar opened this issue Oct 29, 2018 · 5 comments

Comments

@sunnyar
Copy link

sunnyar commented Oct 29, 2018

Thanks for this amazing package.

I have been using the "table2slides2" method call to add dynamic content for a table from your example-demo file but it seems the addText options parameter has no effect to the text content whatsoever.

i.e If I change the fontSize, color etc. it doesn't apply to the text.

Can you please fix it.

@gitbrent
Copy link
Owner

Hi @sunnyar

So you're using the addText() option in your addSlidesForTable() method call?

Please provide the code and the output.

API Docs

@sunnyar
Copy link
Author

sunnyar commented Oct 31, 2018

table text issue
Hi @gitbrent ,

Thanks for the reply.

My code snippet is as below:

var pptx = new PptxGenJS();
pptx.setLayout('LAYOUT_WIDE');
var objOpts = {x:1.10, y:0.8, h:"100%", master:"MASTER_SLIDE", w:10.3};
objOpts.addText = { text: "Table Title", options:{ x:1.1, y:"10%", color:'0088CC', fontFace:'Arial', fontSize:12 } };
pptx.addSlidesForTable('table-id', objOpts);
pptx.save("tables.pptx");

Attached is the table text which doesn't follow the options settings and is default. The same happens for the Demo Table (Add dynamic text) on the "examples/pptxgenjs-demo.html".

@sunnyar
Copy link
Author

sunnyar commented Oct 31, 2018

Any updates @gitbrent . Is the issue I am facing a bug or am I doing something wrong ?

@sunnyar
Copy link
Author

sunnyar commented Nov 1, 2018

Got it resolved.
The issue is that we need to use "opts" instead of "options" in the addText assignment call for the addSlidesForTables.

Old code
objOpts.addText = { text: "Table Title", options:{ x:1.1, y:"10%", color:'0088CC', fontFace:'Arial', fontSize:12 } };

New Code
objOpts.addText = { text: "Table Title", opts:{ x:1.1, y:"10%", color:'0088CC', fontFace:'Arial', fontSize:12 } };

As per Line 5307 in pptxgen.js

if ( opts.addText ) newSlide.addText( opts.addText.text, (opts.addText.opts || {}) );

Thank You

@gitbrent
Copy link
Owner

gitbrent commented Feb 8, 2019

Thanks @sunnyar

The code and the documentation did not match, hence opts working instead of options

I've updated the code to now accept either one.

@gitbrent gitbrent closed this as completed Feb 8, 2019
gitbrent added a commit that referenced this issue Feb 8, 2019
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this issue Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants