Initially, I utilized an SVG as a background image in the CSS of my HTML file and attempted to convert it to PDF using HtmlConvert.convertToPdf
. However, my SVG images are experiencing styling issues where the colors are inverted, showing black as white and vice versa, and moreover, Chinese characters fail to display properly. I encountered limitations with html2pdf’s support for SVG. Subsequently, I tried converting the SVG directly to PDF using SvgConvert.createPdf
, only to find that the SVG still presented similar issues. This leads me to believe that there might be inadequate support for SVG processing, regardless of the method used. Here is my code:
SvgConverterProperties prop = new SvgConverterProperties();
FontProvider fontProvider = new FontProvider();
PdfFont pdfFont = PdfFontFactory.createFont("/font/HYWenHei-75W.ttf,PdfEncodings.IDENTITY_H");
fontProvider.addFont(pdfFont.getFontProgram());
prop.setFontProvider(fontProvider);
SvgConvert.createPdf(new FileInputStream('test.svg'),new FileOutPutStream('test.pdf'),prop);
the svg file like text
I’m not sure if this is a bug; could someone please help me with this? Thank you.
Is there a solution from the user’s coding perspective to address this issue, or could developers resolve it and release an update? Please assist with this.
李当心 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.