Giter VIP home page Giter VIP logo

Comments (12)

TheDarkStrix avatar TheDarkStrix commented on July 18, 2024 8

Hey guys,

Any progress in this regard ?

from html-to-docx.

ortonomy avatar ortonomy commented on July 18, 2024 1

I was able to reproduce this issue with the test HTML

from html-to-docx.

brockfanning avatar brockfanning commented on July 18, 2024

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.

privateOmega avatar privateOmega commented on July 18, 2024

@brockfanning Could you please post a test HTML string so as to replicate the issue?

from html-to-docx.

brockfanning avatar brockfanning commented on July 18, 2024

@privateOmega I tested it by adding <p> tags in the node example, like so: brockfanning@e40026a

from html-to-docx.

KeithGillette avatar KeithGillette commented on July 18, 2024

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.

KeithGillette avatar KeithGillette commented on July 18, 2024

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.

tgv1975 avatar tgv1975 commented on July 18, 2024

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.

privateOmega avatar privateOmega commented on July 18, 2024

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.

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.

zeljko-bulatovic avatar zeljko-bulatovic commented on July 18, 2024

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.

tgv1975 avatar tgv1975 commented on July 18, 2024

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:
image

Here's the .docx output, in Word (image missing):
image

Attached, the .docx itself, for investigation:

test.docx

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.

xiuluo211314 avatar xiuluo211314 commented on July 18, 2024

I have same problem. I need help!!!

from html-to-docx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.