PowerPoint to PDF conversion gives different results on Windows and Mac

Starting to investigate test failures on our non-Windows builds and a lot of them are due to various differences in the output on each platform.


This ticket is for PowerPoint in particular, because this one doesn’t look like it’s just a font issue. If you look at the screenshot, I have marked the height of the text - the text on the Mac version is a few points larger than the text on the Windows version.

Aside from the fonts being different on each computer (which is sort of a fact of life), I can’t see why the results would be different. And fonts being different wouldn’t explain (for me) why the size would be different between the two. I can’t easily figure out which font it’s looking up. Is there some kind of diagnostics hook for this? It would be helpful if during unit tests, automatic font replacement did not take place - outright failure is more useful.

The test program is nothing special:

try (InputStream stream = new FileInputStream(new File(“in.pptx”))) {
PresentationEx presentation = new PresentationEx(stream);
try {
HeaderFooterManagerEx headerFooterManager =
presentation.getHeaderFooterManager();
headerFooterManager.isDateTimeVisible(false);

File pdfFile = new File(“out.pdf”);
presentation.save(pdfFile.getAbsolutePath(), SaveFormat.Pdf);
} finally {
presentation.dispose();
}
}

Hi Nuix,


I have observed the issue statement and data shared by you. I suggest you to please try using Aspose.Slides for Java 8.3.0 on your end if you are not using the latest version. If there is still an issue then please share the details about the JDK installed and MAC\Windows version along with other environments details (if any), so that I may help you further in this regard.

Many Thanks,

I’m attaching the results for v8.3.0. Each image looks different to the previous results, but the two results look different to each other still, as well as the positioning being different.


Hi Nuix,


I have observed the snapshot shared by you. It seems that there are two different fonts renderings in two operating systems. The source presentation has Calibri font but in Mac it is rendered with Arial. There can be two issues in this situation. First is that the Calibri font is missing in your Mac installation. For this, I suggest you to please copy the Calibri font from your Window installation and use that in your Mac without installing that. Please use the following sample code on your end inside MAC application before loading the presentation.

String[] _fontDir = new String[] {fontDir};
FontsLoader.loadExternalFonts(_fontDir);

The fontDir is the place where you will copy the Calibri font. If the issue is due to missing font then it should be resolved here.

The second situation is that you may be using a Java version on Mac that has inherited rendering issue with Calibiri fonts. I like to share that Calibri font issue is related to JDK rather than Aspose.Slides. As a solution to the problem completely we suggest to use a different version of JDK. The Calibri font bug exists in JDK 1.6_45 and JDK 1.7_21. There is no issue in JDK 1.6_38, JDK 1.6_39, JDK 1.6_41, JDK 1.6_43, JDK 1.7_17, JDK 1.7_25.

Please share, if I may help you further in this regard.

Many Thanks,
Hi again. I'm back with more information, but mostly bad news.

I worked in some code in our tests to use a different font directory so that I could ensure that all tests on all platforms would run against the same set of fonts. I feed this same, single font directory into all of the Aspose libraries and they seem to pick it up.

The initial tests show that even though the PDF file now has the correct font, the position of all the text is subtly different - all the "centred" text is slightly to the right on Mac OS X. So either Windows is correct and Mac OS X is rendering it too far to the right, or Mac OS X is correct and Windows is rendering it too far to the left.

Also, as you can see, that the bullets and dash are slightly different between the two.

simple_2010_hideHiddenSlides.png is the expected output (created on Windows.)
simple_2010_hideHiddenSlides_generated.png is the actual output (created on Mac OS X.)

Hi Nuix,


Thanks for sharing the detailed analysis with us. I have been able to observe the issues stated on my end. I suggest you to please try using Aspose.Slides for Java 8.5.0 on your end first. If there is still an issue then please share the thumbnails from Mac and Windows with us using the specified API along with source presentation and used sample code. I will add a ticket in our issue tracking system to resolve the issues on our end.

Many Thanks,

Still happens on v8.5.0. Actually, the difference is even more pronounced on 8.5.0.


Sample code is the same as what I originally posted, modified just to set the font directory and licence. Input file is the same. I’m attaching the output from v8.5.0.

public static void main(String[] args) throws Exception
{
File inFile = new File(“test-data/office/ms/powerpoint/simple_2010.pptx”);
File outFile = new File("/Data/simple_2010_mac.pdf");

new com.aspose.slides.License().setLicense(new ByteArrayInputStream(LICENCE_DATA.getBytes(StandardCharsets.UTF_8)));

FontsLoader.loadExternalFonts(new String[] { new File(“test-data/printing-fonts”).getAbsolutePath() });

try (InputStream stream = new FileInputStream(inFile)) {
PresentationEx presentation = new PresentationEx(stream);
try {
HeaderFooterManagerEx headerFooterManager =
presentation.getHeaderFooterManager();
headerFooterManager.isDateTimeVisible(false);

presentation.save(outFile.getAbsolutePath(), SaveFormat.Pdf);
} finally {
presentation.dispose();
}
}
}

Hi Nuix,


Thank you for sharing the quick feedback. I have been able to observe the issue in shared data. I have created an issue with ID SLIDESJAVA-34346 in our issue tracking to investigate and resolve the text shifting issue. A separate issue with ID SLIDESJAVA-34347 has been created to investigate and resolve the bullet rendering issue. This thread has been linked with the issues so that you may be automatically notified once the issues will be resolved.

We are sorry for your inconvenience,

Hi Nuix,


We have initiated investigation of issues associated with this thread on our end. Can you please share the MAC and Windows exact versions along with complete Java version information installed in specified operating systems on your end.

Many Thanks,

Hi Nuix,

Our development team has investigated the issue SLIDESJAVA-34347. It has been observed that Presentation simple_2010.pptx uses Arial font for bullets. Please install Arial font or to copy Arial font in your MAC and use FontsLoader.LoadExternalFonts() method to load that externally. Please share, if I may help you further in this regard.

//Loading font directory
FontsLoader.loadExternalFonts(new String[]{path+“Font\”});


Many Thanks,
  1. We have that font already. It’s a standard font shipped with the OS.
    2. As you can see from our screenshots, the bullets are exactly the same size.
    3. Font differences don’t explain the text being in a completely different position.
    4. Please write some unit tests of your own as it’s pretty obvious you’re not doing it already.

Hi Nuix,

Thanks for your feedback. I have shared the comments with our development team in respective associated ticket and will get back to you as soon as any further information is shared by our development team in this regard.

Many Thanks,

Hi Nuix,

Our development team has investigated the issue on their end. Actually, in the attached images generated in Mac the Aspose.Slides has used Calibri font for bullets instead of Arial font.
Can you please share the Arial and Calibri fonts directories on your Mac installation. It will help us to understand why Aspose.Slides found Calibri and not found Arial.

Please also provide complete MAC, Windows and complete JDK versions used on both MAC and Windows on your end. Please also not that there are some JDKs like JDK 16_45 and JDK 1.7_21 that have issue with Calibri font rendering. Please also make sure that you must not use the shared JDK versions on your end.

Please share the requested information so that we may help you further in this regard. For the time being you can please use the FontsLoader.LoadExternalFonts() method to load missing Arial font in your MAC environment to get things going on.

Many Thanks,

Attached zip includes Mac and Windows fonts for both Arial and Calibri.


In the case of Windows, all these files are directly from the Windows\Fonts dir.

In the case of Mac OS X, Arial is directly from /Library/Fonts but the Calibri files are copied from Windows and renamed to match the Mac style. So we know that Calibri is the same, at least, but I’m not so sure about Arial.

The JDK is 1.8.0_05 in all cases.

As for FontsLoader.loadExternalFonts… No, it is not a useful workaround.

As part of our attempt to get consistent behaviour across all platforms, we already use FontsLoader.loadExternalFonts to load all fonts used in all tests from a local directory. (You can see that in the code example we already provided as well.)

This local testing fonts directory contains both Arial and Calibri already. Problem is, there is only this “loadExternalFonts” method. I know that FontsLoader loads the system-wide fonts regardless, because we have another ticket open about an AccessControlException caused by it doing that during our unit tests. So that could perhaps also explain the rendering differences. For this sort of reason, it would be very helpful if there were API to set exactly which fonts to use. That way, we would know that there can’t be any other rogue font files being loaded.

Hi,

Thank you for sharing the feedback. I also requested the information about MAC OSX version used on your end as well. Please share the details and version of MAC used on your end.

As far as your following observation is concerned, I like

nuix:
As part of our attempt to get consistent behaviour across all platforms, we already use FontsLoader.loadExternalFonts to load all fonts used in all tests from a local directory. (You can see that in the code example we already provided as well.)

This local testing fonts directory contains both Arial and Calibri already. Problem is, there is only this "loadExternalFonts" method. I know that FontsLoader loads the system-wide fonts regardless, because we have another ticket open about an AccessControlException caused by it doing that during our unit tests. So that could perhaps also explain the rendering differences. For this sort of reason, it would be very helpful if there were API to set *exactly* which fonts to use. That way, we would know that there can't be any other rogue font files being loaded.

The loadExternalFonts method load the fonts from a directory that you have set in arguments of the method. Aspose.Slides loads all the fonts specified in the local directory specified by you just the same way Java loads the fonts from Windows installation. This support is not available that a mechanism may be provided to load the selected fonts in LoadExternalFonts from the directory. You can do this on your end by keeping only those fonts that are required in LoadExternalFonts method directory. You should not place such fonts that are not required in LoadExternalFonts method directory and it also makes sense as well. You can also copy individual fonts in individual directories and then load the directory references on run time for desired fonts only in LoadExternalFonts method. This way you will be able to achieve what you are looking for.

Many Thanks,

Version of OSX being used at the moment is: Mac OS X 10.10.1 (14B25)

At the time the issue was reported, I was on 10.9.something. It still occurs, though.

Regarding your comment about loadExternalFonts, you seem to have misunderstood what I was saying. To summarise:
I do want it to load all fonts from our font directory.
I don’t want it to load any fonts from the system font directory.

As far as I can see, there is no way to tell it not to load the system fonts. Aspose Words and Aspose Cells both have APIs which appear to do this, assuming the method names are accurate.

Anyway, font differences aside, how do you explain the first page – which doesn’t even have any bullets – having the same fonts but two different font sizes? That’s the biggest problem, in my opinion. I don’t care if a bullet is subtly different, and our test framework might not care either. The text being in completely the wrong place at the wrong size definitely causes a failure, though. I think you should fix the bigger issue before worrying about the bullet.


Hi Nuix,

Thank you for sharing the feedback. We are investigating the both issues on our end and will share the feedback with you as soon as the issues will be resolved.

Many Thanks,