singerla / pptx-automizer

A template based pptx generator for Node.js
MIT License
63 stars 11 forks source link

I am having an odd error while essentially following the library #107

Closed Jcoumarb closed 2 months ago

Jcoumarb commented 3 months ago

error:``` C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\reader\DataReader.js:26 throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?"); ^

Error: End of data reached (data length = 0, asked index = 4). Corrupted zip ? at NodeBufferReader.checkIndex (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\reader\DataReader.js:26:19) at NodeBufferReader.checkOffset (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\reader\DataReader.js:17:14) at NodeBufferReader.readData (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\reader\NodeBufferReader.js:14:10) at NodeBufferReader.readString (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\reader\DataReader.js:75:49) at ZipEntries.isSignature (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\zipEntries.js:39:37) at ZipEntries.readEndOfCentral (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\zipEntries.js:164:35) at ZipEntries.load (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\zipEntries.js:255:14) at C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\jszip\lib\load.js:48:24```

code in part" ``const automizer = new pptx2.Automizer({ templateDir:ui/resources, outputDir:ui/resources`, useCreationIds: false, autoImportSlideMasters: true, removeExistingSlides: true, cleanup: false, compression: 0, }); async function test () { let pres = automizer .loadRoot('base.pptx') .load('templateRef.pptx') .load('generated.pptx') .addMaster('generated.pptx', 1) .addSlide('templateRef.pptx', 2) .addSlide('templateRef.pptx', 3)

await pres.write(`create-presentation.test.pptx`);

expect(pres).toBeInstanceOf(pptx2.Automizer);

}

test();```

singerla commented 3 months ago

Hi! I'm sorry about your trouble, but it seems as if one of your .pptx files can't be decompressed by jszip. You could e.g. try to manually extract the contents of base.pptx, templateRef.pptx and generated.pptx and see which one is affected. (try to rename them to .zip and use e.g. 7zip to inflate and see what happens)

Did you create all of your template files with PowerPoint? If not, try to open and save the files in PowerPoint.

Please let me know if I could help.

singerla commented 3 months ago

I'm also seeing this: https://github.com/Stuk/jszip/issues/543. It could be a problem with larger files.