Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sat Nov 19, 2022 10:33 am

Hi,
We are using Spire.PDF version 5.5.0.
Multi-byte characters are garbled when adding SVG as a layer to PDF.

We also tried converting SVG to PNG using Apache Batik. No garbled characters occurred in Apache Batik.

Spire.PDF 5.5.0
OS: Windows10 and Amazon Linux2
JDK: OpenJDK 1.8.0

Code:
Code: Select all
PdfDocument pdf = ...;
int dpiForPdfToPng = ...;
int dpiForPdfToPng = ...;
int pageNumber = ...;
String layerName = ...;

PdfDocument svg = new PdfDocument();
svg.loadFromSvg(svgTmpPath.toString());

Dimension2D d2d = (Dimension2D) svg.getPages().get(0).getSize().clone();
d2d.setSize(d2d.getWidth() * (96.0 / (double) dpiForPdfToPng),
        d2d.getHeight() * (96.0 / (double) dpiForPdfToPng));

PdfLayer pdfLayer = pdf.getLayers().addLayer(layerName);
PdfCanvas canvas = pdfLayer.createGraphics(pdf.getPages().get(pageNumber).getCanvas());
canvas.drawTemplate(svg.getPages().get(0).createTemplate(), new Point2D.Float(0, 0), d2d);

team_ssb
 
Posts: 24
Joined: Fri Nov 26, 2021 1:30 pm

Mon Nov 21, 2022 5:51 am

Hello,

Thanks for your inquiry and sorry to reply late for weekend.
I reproduced your issue and logged it into our bug tracking system with the ticket number SPIREPDF-5625. Our development team will investigate and fix it. Once it is solved, I will inform you in time. Sorry for the convenience caused.

Sincerely
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Fri Dec 02, 2022 9:39 am

Hello,

Thanks for your patient waiting.
After further investigation, we found that the garbled characters is related to the font ‘Arial Unicode MS’. I guess your system lacks the font. I attached the font here, please download it and install it to try again. Then tell us your result. Looking forward to your feedback.

Sincerely
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Wed Jan 04, 2023 8:45 am

Hi,

Hope you are doing well!
Has your problem been effectively solved now? Did you download the font I attached and tested again? Thanks in advance for your feedback and time.

Sincerely
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Fri Jan 13, 2023 9:21 am

Hi,

Hope you are doing well!
Did my answer solve your issue? Could you please give us some feedback at your convenience?

Sincerely
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Return to Spire.PDF

cron