QuestPDF icon indicating copy to clipboard operation
QuestPDF copied to clipboard

Svg with em unit not working

Open eduardo-pellenz opened this issue 6 months ago • 2 comments

Describe the bug

A SVG that we are using is not been rendered.

After some testing, seems to me that 1em is not been handled correctly. Changing to 36 works.

Image

To Reproduce

<svg viewBox="2304 2304 32256 32256" width="1em" height="1em" fill="currentColor">
  <path
    d="M20664 23954.4a289.08 289.08 0 0 0-406.8 0L16074 28137.6c-1936.8 1936.8-5205.6 2142-7344 0-2142-2142-1936.8-5407.2 0-7344l4183.2-4183.2c111.6-111.6 111.6-295.2 0-406.8l-1432.8-1432.8a289.08 289.08 0 0 0-406.8 0L6890.4 18954c-3045.6 3045.6-3045.6 7974 0 11016s7974 3045.6 11016 0l4183.2-4183.2c111.6-111.6 111.6-295.2 0-406.8zm9309.6-17064c-3045.6-3045.6-7974-3045.6-11016 0l-4186.8 4183.2a289.08 289.08 0 0 0 0 406.8l1429.2 1429.2c111.6 111.6 295.2 111.6 406.8 0L20790 8726.4c1936.8-1936.8 5205.6-2142 7344 0 2142 2142 1936.8 5407.2 0 7344l-4183.2 4183.2a289.08 289.08 0 0 0 0 406.8l1432.8 1432.8c111.6 111.6 295.2 111.6 406.8 0l4183.2-4183.2c3042-3045.6 3042-7974 0-11019.6m-8010 6512.4a289.08 289.08 0 0 0-406.8 0l-8154 8150.4a289.08 289.08 0 0 0 0 406.8l1425.6 1425.6c111.6 111.6 295.2 111.6 406.8 0l8150.4-8150.4c111.6-111.6 111.6-295.2 0-406.8z" />
</svg>

eduardo-pellenz avatar May 29 '25 13:05 eduardo-pellenz

Hello,

Hope this isn't a repeat of what you already know. "em" is equal to the element's font-size. I just saved your content to a file, added xmlns="http://www.w3.org/2000/svg" to the root element and opened the file with browser. A small icon is shown. Then, as you suggested, changed the width and height to 36, it got bigger. Then reverted it to 1em and changed the font-size of svg element, and the icon size changed as well. In browsers, the default font size for the root element is 16px.https://stackoverflow.com/questions/41390435/default-reference-font-size-of-em . Changed 1em to 16px and the icon stayed the same size. If you do not see anything on the output pdf, maybe it is zero in QuestPDF's SVG renderer.

burkaysucu avatar May 29 '25 17:05 burkaysucu

@burkaysucu thanks for the response. The icon is drawn correctly on the browser on all cases. It's just not rended on the pdf.

eduardo-pellenz avatar Jul 04 '25 21:07 eduardo-pellenz