html-to-docx
html-to-docx copied to clipboard
width % causes parser error
I have a td tag that has a width attribute of 50% which creates this parsing error: InvalidCharacterError: The string contains invalid characters. Invalid XML name: @w
If I remove the % the parsing engine works fine. The exact markup I have that is causing the issue is:
Is this expected behavior and if so is there a workaround?
i'm having the same problem. did you find out how to address this?
Keeping an eye on this- I contributed some of the code to handle the widths and percents is not something I was thinking about calculating since its relative to the page size. But if you know the page size + margins to draw a box, it would adding a function to convert percents into EMUs (I believe) https://stackoverflow.com/questions/20194403/openxml-distance-size-units
For my scenario it turned out I didn't need the % widths, but since it is valid CSS for a td it would be nice if the parser didn't error. I was fighting with it for a few hours trying to narrow down the issue and finally realized it was the % width causing it to crash.
Facing the same, is there any solution to this?. I removed all the occurances of Width:100% or Width:50% still getting the same error.
Try removing the spaces between the style fields. Let us know if it works for you
Same issue here @BeanoKing , did you find a solution?
I didn't. Ended up moving to a paid solution instead from Apose
@BeanoKing, @mgiraldo, @nicolasiscoding, @abhinovpankaj, @maximesahagian: I opened a PR to fix this at https://github.com/privateOmega/html-to-docx/pull/256
^^ +1 on this