Word found unreadable content in ...



  • When I generate Word files with the docx extension I get this when I'm opening the file. I'm using Word on MacOS. Is this a Mac related problem?

    Here is the exact message text from Word:

    Word found unreadable content in Word.test.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes.


  • administrators

    hi, it is likely that some content inside your docx was not transformed correctly. i mean that likely your document has some kind of content that we were not aware, and need that we handle it to avoid corruption.

    you can share the template you use to produce this content, so we can take a look and fix. i don't think it is a Mac related problem because my development machine uses macos and i never get this messages for the kind of documents we already support.



  • I tried to isolate the problem by removing stuff from the template. As soon as I add {{docxTable}} I get into trouble.

    The only thing in the template file is a table with three columns and the following tags:
    0_1700214197109_upload-6c45153c-bf37-4245-a465-ca2bd63af183

    I wasn't able to upload the document here. I get "you don't have enough privileges for this action".
    I have emailed the template to Jan (didn't have your email).



  • Here is some more insight.
    If I misspell the property for the array, the doc will be empty (reasonable). In this case the warning does not come up.

    My sample dataset only has four items. This is how the document looks when I'm opening it and answer yes to the warning question.

    0_1700214991073_upload-4f00a540-369b-415d-86e2-a18cb5ba1729

    0_1700214942132_upload-5724089a-35ef-470c-862e-0e65d342723d


  • administrators

    thanks, we will take a look and fix what is wrong.


  • administrators

    @msageryd i've tried to reproduce the message you get but i get valid docx, this is the case i am trying https://playground.jsreport.net/w/bjrmatos/zim78tJC

    it is better if you provide a plauygroud link to reproduce, maybe there is something else in your data, maybe some invisible character in the json, who knows, but let me know if you can put a playground that produces such invalid docx.

    also what is your version of Word? not sure if relevant but this is mine

    0_1700498456186_Screenshot 2023-11-20 at 11 .34.44.jpg



  • I forked your playground test and:

    • uploaded my testdata
    • uploaded my docx template again

    The rendered Word file opens up fine in Word at my Mac.

    The only difference is probably the jsreport version. I completely forgot to disclose my version: 3.11.3.
    I see that Playground is at 3.13. I'll try to upgrade my version and post back here.



  • 3.13.0 worked better.
    I suppose something is fixed since 3.11.

    Sorry for not supplying my verison.


  • administrators

    ah ok, glad that it works on recent versions 👍



  • About docx rendering..
    I'm a bit confused between docx and docxtemplater

    When I started out testing this I installed this package in my jsreport Docker image:
    @jsreport/jsreport-docxtemplater

    The naming and the location of the docxtemplater repo has changed over time. Is docxtemplater a different extension than docx?
    What's the difference?
    Which should I use?
    Do I need to install the docxtemplater module in order to use docx?



  • The docxtemplater recipe was our initial "quick win" to support docx format by wrapping already existing library docxtemplater. This was always shipped just as a custom extension.

    In time we realize we can do better by implementing our own docx engine using handlebars and all the features we already have in jsreport - assets, localization, components... This was shipped as docx recipe. This recipe soon became the main part of the jsreport with pptx recipe and xlsx recipe which uses the same approach - typing handlebars inside the office app.

    The docx is now one of the main assets of jsreport and has the similiar popularity as pdf rendering promising long life and main support.

    So you should use the new office recipes docx, pptx and xlsx which are part of the default installation.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.