Hey there! I'm currently using the itext library (html2pdf) to convert my HTML into a PDF. Everything seems to be working fine, except for the SVG styles.
Specifically, this is the part of my HTML code that's causing issues:
<style>
.my-svg{
width: 3.3mm;
height: 3.3mm;
margin-right: 0.4mm;
fill: red;
}
</style>
<svg class="my-svg" width="90.507" height="90.671" viewBox="0 0 23.947 23.99" xmlns="http://www.w3.org/2000/svg">
<path class="darkable" d="PATH" style="stroke-width:.264583;fill-opacity:1" transform="translate(-66.675 -125.148)"/>
</svg>
I attempted to apply the style inline, which did work. However, due to internal constraints (the HTML is dynamically generated and cannot have inline styles set), I need the styles to be under a style
tag.
If you have any insights on why this might be happening or suggestions on how to resolve it, I'd really appreciate your input!
PS: This is the method I use to convert my HTML:
val dir = createPDFReportDirectory()
val pdfFile = File(dir, "$name.pdf").apply { createNewFile() }
val pdfWriter = PdfWriter("$dir/$name.pdf")
val pdfDocument = com.itextpdf.kernel.pdf.PdfDocument(pdfWriter)
val inputStream = ByteArrayInputStream(html.toByteArray())
HtmlConverter.convertToPdf(inputStream, pdfDocument)