gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.96k stars 641 forks source link

writeFile() after write('base64') corrupts table #911

Open sungkimns opened 3 years ago

sungkimns commented 3 years ago

Thank you for reporting an issue, suggesting an enhancement, or asking a question.

We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the Docs to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.

Category

Version

Please specify what version of the library you are using: [ 3.4.0 ]

Please specify what version(s) of PowerPoint you are targeting: [ n/a ]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!

image

Observed Behavior

If you are reporting an issue please describe the behavior you expected to occur when performing the action. If you are making a suggestion or asking a question delete this section.

image

Steps to Reproduce

If you are reporting an issue please describe the steps to reproduce the bug in sufficient detail to allow testing. If you are making a suggestion or asking a question delete this section.

Sample powerpoint generation demonstrating issue.

let ppt = new pptxgen();
let slide = ppt.addSlide();
slide.addTable([
    [
        { text: '1', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '2', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '3', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
    ],
    [
        { text: '4', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '5', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '6', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '7', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
    ],
    [
        { text: '8', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '9', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
        { text: '0', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
    ]
]);
ppt.writeFile('expected');
ppt.write('base64').then(data => { ppt.writeFile('bugged1'); });
ppt.write('base64'); ppt.writeFile('bugged2');

Submission Guidelines

Delete this section after reading

Thank you for your feedback!

gitbrent commented 3 years ago

STATUS: Confirmed using latest method opts

let ppt = new PptxGenJS();
let slide = ppt.addSlide();

slide.addTable([
  [
    { text: "1", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "2", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "3", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
  ],
  [
    { text: "4", options: { colspan: 3, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "5", options: { colspan: 3, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "6", options: { colspan: 3, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "7", options: { colspan: 3, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
  ],
  [
    { text: "8", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "9", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
    { text: "0", options: { colspan: 4, color: "FFFFFF", fill: "000000", border: { pt: 1, color: "FFFFFF" } } },
  ],
]);

ppt.writeFile({ fileName: "expected" });
ppt.write({ outputType: "base64" }).then((_data) => ppt.writeFile({ fileName: "expected" }));
ppt.write({ outputType: "base64" });
ppt.writeFile({ fileName: "bugged2" });