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

Issue 470 - Formatting issues when using percentages #475

Merged
merged 1 commit into from
Jan 26, 2019

Conversation

ReimaFrgos
Copy link
Contributor

PR for Issue: #470

Update the getSmartParseNumber function to use parseFloat instead of parseInt.

When defining heights and widths that use a percentage with a decimal number it use causing minor layout issues due the decimal component being dropped.

Sample code to produce layout issue:

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();

slide.addShape(pptx.shapes.RECTANGLE, { x:0, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:1, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:2, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:3, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:4, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:5, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:6, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:7, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:8, y:1, w:0.87, h:1, fill:'FF0000' });
slide.addShape(pptx.shapes.RECTANGLE, { x:9, y:1, w:0.87, h:1, fill:'FF0000' });

slide.addShape(pptx.shapes.RECTANGLE, { x:0, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:1, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:2, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:3, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:4, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:5, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:6, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:7, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:8, y:2, w:'8.7%', h:1, fill:'0000FF' });
slide.addShape(pptx.shapes.RECTANGLE, { x:9, y:2, w:'8.7%', h:1, fill:'0000FF' });

pptx.save('PptxGenJS-Sandbox_'+getTimestamp());

Sample decks showing the before and after difference based on the above sample code.
parseInt Example.pptx
parseFloat Example.pptx

@gitbrent gitbrent merged commit add0cce into gitbrent:master Jan 26, 2019
@gitbrent gitbrent added this to the 2.5.0 milestone Jan 26, 2019
@gitbrent
Copy link
Owner

Thanks @ReimaFrgos !

gitbrent added a commit that referenced this pull request Jan 26, 2019
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this pull request Mar 24, 2020
Issue 470 - Formatting issues when using percentages
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this pull request 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

Successfully merging this pull request may close these issues.

2 participants