Hello Aspose Support,
I’m using Aspose.PDF for Java 25.8 to insert SVG images into a PDF document. I’m currently loading the SVG using SvgLoadOptions. However, I’m encountering a text rendering issue: the text inside the SVG appears compressed, and characters are overlapping or superimposed in the generated PDF.
After inspecting the SVG, I noticed that many elements use the lengthAdjust=“spacingAndGlyphs” and textLength attributes and it is the source of my issue. If I remove them, the svg inside the pdf is correctly displayed.
Shouldn’t the attributes lengthAdjust=“spacingAndGlyphs” and textLength be supported?
I can provide a sample SVG and PDF if needed.
Thank you in advance for your help,
Best regards,
Stéphane
@Stephen_Cordell
Hello Stéphane,
The issue you’re experiencing with SVG text rendering in the PDF, particularly regarding the lengthAdjust="spacingAndGlyphs"
and textLength
attributes, is known to cause problems in some rendering engines. These attributes can lead to unexpected text compression and overlapping characters.
Currently, Aspose.PDF may not fully support these specific SVG attributes, which is why removing them resolves the rendering issue. Unfortunately, there isn’t a direct workaround within the library to handle these attributes correctly.
As a potential solution, you could preprocess the SVG to remove or adjust these attributes before loading it into the PDF. Alternatively, if the text does not need to be selectable in the PDF, consider converting the SVG to a raster format such as PNG or JPEG.
If you need further assistance or would like to share a sample SVG and PDF for more specific guidance, please feel free to do so.
Best regards!