guigrpa / docx-templates

Template-based docx report creation
MIT License
908 stars 146 forks source link

HTML (altchunk) not supported/displayed when opening in LibreOffice #201

Open pawepaw opened 3 years ago

pawepaw commented 3 years ago

Wanted to use docx templates in our process to generate a pdf report. Just spotted that LibreOffice isn't displaying that HTML rendered with docx-templates altchunk at all.

Is it only me who is experiencing such problems? Is there any other option to render HTML that's gonna be opened by LibreOffice?

jjhbw commented 3 years ago

I expect this to be a LibreOffice thing. Leaving this open for others to comment.

pawepaw commented 3 years ago

yes that's totaly LibreOffice thing. Just wanted to ask if you're aware of any workaround.

pawepaw commented 3 years ago

i.e i see that https://docxtemplater.com/demo/#html is handling that perfectly. Embedded some HTML table and libre office displays it properly. hmmmm

jjhbw commented 3 years ago

So you mean that it should be possible? If you can find what exactly it does differently (i.e. does the HTML look different?) we may be able to build a patch.

pawepaw commented 3 years ago

well I'm not sure if it should be possible, not an expert on that field. I've checked docxtemplater result and it seems that they are generating openxml based on provided HTML, so it's basically different approach.

veich commented 3 years ago

HTML is not generated for me as well - like it "eats" all the HTML and all I get nothing in the places where HTML should have been. I'm using version "docx-templates": "^4.5.4" EDIT: not visible in latest version as well: "docx-templates": "^4.6.0"

veich commented 3 years ago

well I'm not sure if it should be possible, not an expert on that field. I've checked docxtemplater result and it seems that they are generating openxml based on provided HTML, so it's basically different approach.

what is the relationship between docxtemplater (which is commercial product) and this lib?

jjhbw commented 3 years ago

what is the relationship between docxtemplater (which is commercial product) and this lib?

There is none. Just a slightly inconvenient naming similarity ;)

veich commented 3 years ago

FYI @all partial solution (at least the one I opted for) docx is basically .zip-ed xml so my plan is to directly edit xml so I don't have to use libraries (except some for XML manipulation but that is pretty straightforward)

qngdt commented 3 years ago

FYI @ALL partial solution (at least the one I opted for) docx is basically .zip-ed xml so my plan is to directly edit xml so I don't have to use libraries (except some for XML manipulation but that is pretty straightforward)

Could you be more specific about your approach? I'm having the same issue.

veich commented 3 years ago

Could you be more specific about your approach? I'm having the same issue.

unzip the .docx file and go to word/document.xml you can view and edit the file and that's it look how current structure looks like and just imitate the elements you wish to add and that's it

carlosconnected commented 3 years ago

I have the same issue. What I noticed is that LibreOffice can properly display html directly. For example, if I open a html file (with html content) and save it as a docx, it still displays the content correctly. The problem seems to be the embedding of html in this library that it only renders properly in MS Word. It does not render on Libre Office, Open Office or Google Docs. At least in my case working on Mac.

carlosconnected commented 3 years ago

So apparently this is due to lack of support for altchunk as it seems to be non-standard. Even MS Word re-formats/re-parses the files with altchunk if you "save as" the docx.

Hariprasath-G commented 3 years ago

Please note that until a document that contains altChunk elements is opened and saved in Office, it still contains the altChunk parts, and not normal WordprocessingML markup of paragraphs, runs, and text elements. The solution with SharePoint 2010 is that you can use Word Automation Services to update the documents that contain altChunk elements. After Word Automation Services processes it, the document will contain paragraphs, runs, and text elements.

https://ankushbhatia.wordpress.com/2010/10/22/altchunk-an-interesting-scenario/?unapproved=4594&moderation-hash=4178e78d24528e1c1c061e585d38bdc8#comment-4594

FelixRelli commented 1 year ago

Instead of relying on altchunks it could be done similar to what https://www.npmjs.com/package/html-to-docx does.

Akbar0102 commented 1 year ago

Is there a solution for this? I have been using it to generate DOCX files and then convert them to PDF. Everything worked well on Windows, but when I moved to Linux and started using LibreOffice, the generated DOCX files do not display content from HTML. This also affects the generated PDF files.

aeruggiero commented 3 months ago

Is there a solution for this? I have been using it to generate DOCX files and then convert them to PDF. Everything worked well on Windows, but when I moved to Linux and started using LibreOffice, the generated DOCX files do not display content from HTML. This also affects the generated PDF files.

Up, I entirely quote this. Same issue I'm facing now. Does anyone have any workaround?