PavelS0 / docx_template_dart

A Docx template engine
Apache License 2.0
40 stars 20 forks source link

Word file gets corrupted #37

Closed AbdullahNaveed closed 1 year ago

AbdullahNaveed commented 1 year ago

I am trying to edit a very simple word file with 1 control tag. Word file is fetched correctly and displayed, but when I use docGenerated = await docx.generate(c);

The file gets corrupted. I am using Office 2016 to create word files.

Screen Shot 2022-11-28 at 3 20 49 PM

Code:

Screen Shot 2022-11-28 at 3 21 16 PM
ShineYang commented 1 year ago

Same problem, it's strange that I've already successfully generated target document fews days before, with the same code. I tried to downgrade flutter sdk to earlier version (3.5 ~ 3.8) but it doesn't work.

kungege commented 1 year ago

@PavelS0 Could you take a look at this, please?

ShineYang commented 1 year ago

@AbdullahNaveed Found a temporary solution here, just override this dependency in pubspec.yaml

dependency_overrides:
  archive: 3.3.0
AbdullahNaveed commented 1 year ago

@AbdullahNaveed Found a temporary solution here, just override this dependency in pubspec.yaml

dependency_overrides:
  archive: 3.3.0

Works like a charm!!! Thanks so much brother <3

weimuhua commented 1 year ago

@AbdullahNaveed Found a temporary solution here, just override this dependency in pubspec.yaml

dependency_overrides:
  archive: 3.3.0

you save my life bro!

marcov-dart commented 1 year ago

As a hint to the maintainers: I just came across this same problem in a bit of my own code. It worked for archive 3.3.0 but with archive 3.3.5 the resulting zip file is truncated. I am reading a zip file into Archive and then making a new Archive copying adding of the original ArchiveFile objects but replacing some. Probably very similar to what is being done here. I had to make new ArchiveFile objects with the name, size and contents of the original (make a copy) and add that copy to the new archive instead of the ArchiveFile objects from the original.

Terranic commented 1 year ago

Great, thanks!

this one seems to work as well, but with 3.3.3 the docx is becoming corrupted dependency_overrides: archive: 3.3.2

WilliansDutra commented 1 year ago

I have the same problem.

I have tried with and without the dependency overrides, tried the code from sample, tried my own template file and template file from docs.

I'm starting to get bald with this lol

image image image

Fiat2U commented 1 year ago

Great, thanks!

this one seems to work as well, but with 3.3.3 the docx is becoming corrupted dependency_overrides: archive: 3.3.2

I used your code in https://github.com/Fiat2U/docx_template_flutter_sample.

Fiat2U commented 1 year ago

@WilliansDutra You may want to try https://github.com/Fiat2U/docx_template_flutter_sample.

WilliansDutra commented 1 year ago

@Fiat2U made a test using the link and it worked! Now I'll try within my project. I'll post here the update.

PavelS0 commented 1 year ago

Probably fixed in de19046