PPTX to SVG/PNG - Odd Character Bolding when Converting Chinese Characters

Hello all,

I’m having a bit of an odd Aspose issue that I was hoping someone could help me with. I’m using Aspose slides to convert ppt slides into PNG and SVG images, but for some reason the api is failing to properly convert some Chinese characters. Rather than simply importing the characters as-is, the Aspose library is intermittently bolding random characters in sentences. It’s not like the whole sentence is bold, it’s just random characters here and there. Here is a sample of the issue:

PPT:
image.png (4.2 KB)

SVG:
image.png (5.9 KB)

Any help would be much appreciated!

@ggrieco,
Thank you for the issue description. Could you also share a code example and presentation samples for investigation, please?

Hey Andrey,

I don’t see an option to upload a PPT.

Here is a code snippet from our conversion code. Let me know if you need anything else:

LoadOptions lo = new LoadOptions(LoadFormat.Auto);
lo.setDefaultRegularFont(“Arial Unicode MS”);
lo.setDefaultAsianFont(“Arial Unicode MS”);
lo.setDefaultSymbolFont(“Arial Unicode MS”);
Presentation pres = new Presentation(file.getInputStream());
// Getting last slide index
int lastSlidePosition = pres.getSlides().size();
ISlide slide = null;
JPEGTranscoder t = new JPEGTranscoder();
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));
// Iterating through every presentation slide and generating SVG image
List newSlides = new ArrayList();

	for (int i = 0; i < lastSlidePosition; i++) {
		logger.debug("Generating slide: " +i);
		ImportedSlide importedSlide = new ImportedSlide();
		// Accessing Slides
		slide = pres.getSlides().get_Item(i);
		BufferedImage buffImage = slide.getThumbnail((float)1.5, (float)1.5);
		String b64 = imgToBase64String(buffImage, "png");

@ggrieco,
Thank you for the code snippet. A presentation sample is very important for the issue investigation. The presentation files (and any other) can be uploaded using the same button “Upload” that you used for attaching PNG files.

Ah, I had to zip it up. Here you go: ChinesePresentationSample.zip (2.8 MB)

@ggrieco,
Thank you for the presentation sample. I have reproduced the problem and got the same results. I have logged the issue in our tracking system with ID SLIDESJAVA-38441. Our development team will investigate the issue. You will be notified when it is fixed.

@Andrey_Potapov
Do you have any time table on when this fix might be coming? This is a production issue for me and I have folks checking in daily.

@ggrieco,
Our development team has replied to me that the issue will be investigated next week (2021/W05). After that, we can inform you ETA.

@ggrieco,
We have a known issue with Chinese characters and Arial font. I would suggest you to try font substitutions as follows:

Presentation presentation = new Presentation(resourcesOutputPath + "/ChinesePresentationSample.pptx");

FontSubstRuleCollection substRules = new FontSubstRuleCollection();
FontData sourceFont = new FontData("Arial");
FontData destFont = new FontData("Microsoft JhengHei");
FontSubstRule substRule = new FontSubstRule(sourceFont, destFont, FontSubstCondition.Always);
substRules.add(substRule);
presentation.getFontsManager().setFontSubstRuleList(substRules);

ISlide slide = presentation.getSlides().get_Item(0);
BufferedImage image = slide.getThumbnail((float) 1.5, (float) 1.5);

File pngFile = new File(resourcesOutputPath + "/out_img.png");
ImageIO.write(image, "png", pngFile);

slide.writeAsSvg(new FileOutputStream(resourcesOutputPath + "/out_img.svg"));

Hey Andrey,

Our feature doesn’t only support Chinese characters though. We wouldn’t want to change the font set across the board. Is there any way to detect Chinese characters in the ppt and then change the font? Or is there any way to fix the Arial bug so we don’t need to manipulate fonts in the Java?

@ggrieco,
To my regret, the issue will take a long time to resolve. You can try the fallback mechanism for some character ranges so that you don’t replace the fonts entirely. More details: Set Font FallBack. If it does not help you, the development team will continue to work on this issue.

Hey Andrey,

Your link results in a 404. Are you sure that’s the correct doc?

@ggrieco
Most likely the documentation was recently changed. I will find out what happened. Please take a look at the article Use for Font FallBack and Prompt Text using Aspose.Slides for .NET and Java.
API Reference: IFontFallBackRule interface

@ggrieco

I was informed that documentation was updated. That link is not correct now. The new article can be found here: Fallback Font.

The issues you have found earlier (filed as SLIDESJAVA-38441) have been fixed in this update.

Hey,

We tried running a sample through the updated library and it still isn’t working for us. We seem to have found one potential cause of the issue. It looks like SimHei font is not being recognized by the Aspose library and that is causing the characters to render improperly. When we changed to font to other font families it was interpreted correctly.

@ggrieco,
To my regret, the notification has been sent automatically because the issue is closed (without a solution). Could you share both presentations (with the problem and without one), please?