Comments (12)
Hey guys,
Any progress in this regard ?
from html-to-docx.
I was able to reproduce this issue with the test HTML
from html-to-docx.
After a bit more experimentation I think it may be a bug caused by the image being wrapped in a <p>
tag. I'll update the issue title.
from html-to-docx.
@brockfanning Could you please post a test HTML string so as to replicate the issue?
from html-to-docx.
@privateOmega I tested it by adding <p>
tags in the node example, like so: brockfanning@e40026a
from html-to-docx.
I believe this issue is not limited to p
tags. Images also do not render when nested at some level inside most tags other than div
, th
, or td
. In my limited testing this includes:
- span
- li
- blockquote
- strong
- i
- u
from html-to-docx.
I've spent a few hours poking around and I think the issue is that the xml-builder only checks for buildImage
when processing select elements like divs and tables but not when building paragraphs of inline elements or blockquotes. Unfortunately, I can't find the right place(s) to insert additional calls to buildImage
to correct the problem. My attempts lead to call stack overflows or only limited additional tags actually working. Any pointers, @privateOmega ?
from html-to-docx.
I can reproduce the issue. In my case, the image with src
set to a data url (base64
) does not make it into the export even if it's wrapped in a div
. Basically, no images are exported. I'm testing the export with MS Word 2013 and LibreOffice 7.
It would be awesome if this was fixed.
@privateOmega Thanks for your work on this! Not an easy feat.
from html-to-docx.
I can reproduce the issue. In my case, the image with
src
set to a data url (base64
) does not make it into the export even if it's wrapped in adiv
. Basically, no images are exported. I'm testing the export with MS Word 2013 and LibreOffice 7.It would be awesome if this was fixed.
@privateOmega Thanks for your work on this! Not an easy feat.
Thanks. Could you please post a sample html code containing base64 image you were trying out for me to test, I have tried a png and a jpeg images in base64 and both are getting rendered?
from html-to-docx.
Hi, i have the same issue. Here is the non-working example:
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> </head> <body> <p>Test</p> <p></p> <p> <div> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="> </div> </p> <p></p> <p>Test</p> <p></p> <p> <div> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="> </div> </p> <p></p> <p></p> </body> </html>
Just remove outer p tag around div, and it will work, like in the following example:
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> </head> <body> <p>Test</p> <p></p> <div> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="> </div> <p></p> <p>Test</p> <p></p> <div> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="> </div> <p></p> <p></p> </body> </html>
from html-to-docx.
Thanks. Could you please post a sample html code containing base64 image you were trying out for me to test, I have tried a png and a jpeg images in base64 and both are getting rendered?
First, sorry for the late reply. Here is how I'm doing it, and the image doesn't make it into the .docx:
Minimal test markup (using the image above, used by @zeljko-bulatovic):
<h1>This is the title</h1><p>This is some text.</p><img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="><p>Some more text.</p>
This is how the HTML rendering looks:
Here's the .docx output, in Word (image missing):
Attached, the .docx itself, for investigation:
Looking into the .docx source itself, I can't find any reference to the image. I'm stumped. Hopefully you'll be able to debug this.
Thank you!
PS: worth noting that I'm converting in the browser, not in a Node.js backend.
from html-to-docx.
I have same problem. I need help!!!
from html-to-docx.
Related Issues (20)
- minifyHTMLString is not a function
- Lang / time new roman font is not working
- feature: 2 Columns in page
- style改变字体,数字变了,中文还是Times New Roman
- support for line breaks like <br> tag HOT 2
- imgs with src as base64 do not come over
- Is width = 100% achievable?
- How to resize images - is it possible?
- Images & style doesn't apply well in .docx file HOT 4
- html to docx conversion raise an error when it transform a table with merged cell
- Margins don't work
- ADD page break if content doesn't have enough room
- XML error when using with Vite (React or Vue)
- browser webpack error
- How to preserve border-bottom without table
- Refactoring work done HOT 4
- bug: when an image is nested under spans, xml-builder doesn't pick up the img tag
- README.md does not show how to load the HTMLtoDOCX function HOT 2
- Nested formatting tags are not getting applied
- STRIKE THROUGH Not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-to-docx.