Improper thumbnails generated in MAC and Linux (Java)

Hello,

We are using aspose-lides 20.1 and see different page preview image rendered on Linux and IOS. On IOS the rendering image match the original ppt file, but on linux we are seeing some image/shape disposition and missing text. Related ppt and image files are here
files.zip (6.5 MB)

Our code to generate previews:

Double height = getPageSize().getHeight();
Double width = getPageSize().getWidth();
ISlide islide = presentation.getSlides().get_Item(pageNumber);
Dimension dimension = new Dimension(width.intValue() * PPT_PREVIEW_SCALE, height.intValue() * PPT_PREVIEW_SCALE);
return islide.getThumbnail(dimension);

Thanks,
Yuanwei

@yuanwliu,

I have worked with sample files shared by you using Aspose.Slides for Java 20.5 and have not been able to observe issue in generated thumbnails. Please check the attached generated thumbnails. I suggest you to please try using suggested version.

Secondly, for text missing in thumbnail of SmartArt shape in slide_templates_20.pptx. It is not an issue. The word, “Text” that you see in PowerPoint is actually a default indication text appearing in PowerPoint and is for user reference that he needs to add text here. If you check the SmartArt bullets, you will find empty text there and nothing is saved in presentation. Therefore, when API render, it render without text. It is not an issue with API. You can try adding any text and then check whether it is rendered in thumbnail or not.

ppt_file.zip (676.0 KB)

SynonymandAntonymLessonFreebie.zip (6.0 MB)

Thanks for replying. I did a fat jar testing with 20.5 on the linux ec2 instance and unfortunately still see the image overlap issue, images as attached here 20.5-previews.zip (6.9 MB). Not very clear why we see different results with 20.5 though.
The details of the linux server: Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-1107-aws x86_64)
Test file I am using ImageTestBase.java.zip (1.3 KB)

Thanks,
Yuanwei

@yuanwliu,

Can you please confirm the following scale layout percentage on your end. It should be 100%. If it is more than that you may observe cropping of text. I have observed text cropped in new images shared by you.

Please also share the JDK version used on your end too. For scaling information, you can check this link.

The JDK version is openjdk version “1.8.0_252”.
There are some misunderstanding in the current title: actually we are not seeing any issues with thumbnails generated on IOS, it works just fine even with 20.1. Only when we deploy to linux remote servers we start seeing image overlapping. I did ssh to remote linux server but can’t find/set scaling there.

Thanks
Yuanwei

@yuanwliu,

Is it possible for you to please verify the resolution of your remote server. It does not seems to be an API issue as neither issue occurs in Windows or MAC. Is it possible for you to please try using some other Linux machine as I have checked the presentation decks too and they are pretty much simple presentations. In my opinion, it doesn’t seems to be an API issue as even MAC produces correct output which is UNIX based too.

I can’t try other Linux server as we finally are using Aspose as part of our service in current Linux instances, so I need to get it work on current EC2 instance any way. I don’t find the resolution, but I tried headless mote with System.setProperty(“java.awt.headless”, “true”); still it produces overlap images.

@yuanwliu,

We will await further feedback from your end as soon as you will be able to try on your end.

A few points here:

  1. The test is running in headless mode(without a graphical console), why would the point of setting resolutions on the system arise?
  2. Amazon ec2 linux instances do not come with a GUI and we didn’t install any GUI so even setting resolutions on the instance doesn’t come to pictures generated.

@yuanwliu,

I agree with you on this. The suggestions of screen resolution verification was made when you have not provided the info about using running headless machine on your end. We have investigated a bit further and it seems that your headless machine does not have used fonts available. Can you please ensure the availability of the fonts on your machine and load them externally.

I added following code to my test:

    String[] fontDir = new String[] { "/opt/content/fonts/" };
    FontsLoader.loadExternalFonts(fontDir);
    String[] result = FontsLoader.getFontFolders();

/opt/content/fonts is a folder we added to be used in certain places.

Above “String[] result = FontsLoader.getFontFolders();” generates an array with following output:
/opt/content/fonts (attached here opt.zip (3.8 MB) )
/usr/share/fonts (a fairly large folder about 25 mb can not attach here)
/usr/local/share/fonts (empty folder)
fonts (not exist)
/home/ubuntu/.fonts (not exist)

@yuanwliu,

Can you please share did the approach of loading the fonts used in presentation externally worked or not on your end? Is it still the same or improved/

sorry forgot to mention it’s the same output, nothing changed

@yuanwliu,

I have checked opt.zip. The following fonts have been used in your presentation files. However, I am unable to find any of these fonts in opt.zip that I am assuming is list of fonts on your Amazon Ec2 Linux machine.

Can you please ensure availability of the fonts on your end and also share the JDK you have used.

The Following Fonts have been used in presentation: SynonymandAntonymLessonFreebie.pptx
Font Used: Arial
Font Used: Calibri Light
Font Used: Calibri

The Following Fonts have been used in presentation: ppt_file.ppt
Font Used: Arial
Font Used: Wingdings
Font Used: Calibri
Font Used: Times New Roman
Font Used: Tahoma
Font Used: Calibri Light

I am also assuming that you are using the following sample code as it is on your end. The only change needed is updating the presentation and folder name.

        String[] fontDir = new String[] { "/opt/content/fonts/" };
        FontsLoader.loadExternalFonts(fontDir);
        
        Presentation presentation=new Presentation("Test.pptx"); 

        String nameFolder="Deck_1";        
        //String[] result = FontsLoader.getFontFolders();
    
        int slideSize = presentation.getSlides().size();

        File dir = new File(nameFolder);
        dir.mkdirs();

        for (int i = 0; i < slideSize; i++) {
            BufferedImage bufferedImage = presentation.getSlides().get_Item(i).getThumbnail(2.0f, 2.0f);
            int slideNumber = i + 1;
            ImageIO.write(bufferedImage, "png", new File(dir, "Slide" + slideNumber + ".PNG"));
        }

I am using the FontsLoader as you used in the sample code above.
My JDK version is openjdk version “1.8.0_252”.

/opt/content/fonts are fonts we put to linux instance, the instance comes with a folder of fonts /user/share/fonts
I did a “fc-list” on linux instances (this command will list all installed fonts) and don’t find any of the fonts you listed (Arial, Calibri Light etc.)
Do you think the missing fonts is a cause of the improper previews?

FYI: the out put of “fc-list” is as below:

indent preformatted text by 4 spaces
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/type1/gsfonts/n021024l.pfb: Nimbus Roman No9 L:style=Medium Italic
/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/type1/gsfonts/n021004l.pfb: Nimbus Roman No9 L:style=Medium
/usr/share/fonts/type1/gsfonts/p052023l.pfb: URW Palladio L:style=Italic
/usr/share/fonts/type1/gsfonts/n022003l.pfb: Nimbus Mono L:style=Regular
/usr/share/fonts/type1/gsfonts/z003034l.pfb: URW Chancery L:style=Medium Italic
/usr/share/fonts/type1/gsfonts/c059013l.pfb: Century Schoolbook L:style=Roman
/usr/share/fonts/type1/gsfonts/d050000l.pfb: Dingbats:style=Regular
/usr/share/fonts/type1/gsfonts/n021023l.pfb: Nimbus Roman No9 L:style=Regular Italic
/usr/share/fonts/type1/gsfonts/n019063l.pfb: Nimbus Sans L:style=Regular Condensed Italic
/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
/usr/share/fonts/type1/gsfonts/a010013l.pfb: URW Gothic L:style=Book
/usr/share/fonts/type1/gsfonts/n019064l.pfb: Nimbus Sans L:style=Bold Condensed Italic
/usr/share/fonts/type1/gsfonts/p052004l.pfb: URW Palladio L:style=Bold
/usr/share/fonts/type1/gsfonts/n022023l.pfb: Nimbus Mono L:style=Regular Oblique
/usr/share/fonts/type1/gsfonts/a010015l.pfb: URW Gothic L:style=Demi
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
/usr/share/fonts/type1/gsfonts/n019043l.pfb: Nimbus Sans L:style=Regular Condensed
/usr/share/fonts/type1/gsfonts/n019044l.pfb: Nimbus Sans L:style=Bold Condensed
/usr/share/fonts/type1/gsfonts/a010033l.pfb: URW Gothic L:style=Book Oblique
/usr/share/fonts/type1/gsfonts/n021003l.pfb: Nimbus Roman No9 L:style=Regular
/usr/share/fonts/type1/gsfonts/s050000l.pfb: Standard Symbols L:style=Regular
/usr/share/fonts/type1/gsfonts/b018035l.pfb: URW Bookman L:style=Demi Bold Italic
/usr/share/fonts/type1/gsfonts/c059033l.pfb: Century Schoolbook L:style=Italic
/usr/share/fonts/type1/gsfonts/a010035l.pfb: URW Gothic L:style=Demi Oblique
/usr/share/fonts/type1/gsfonts/n019023l.pfb: Nimbus Sans L:style=Regular Italic
/usr/share/fonts/type1/gsfonts/b018012l.pfb: URW Bookman L:style=Light
/usr/share/fonts/type1/gsfonts/c059016l.pfb: Century Schoolbook L:style=Bold
/usr/share/fonts/type1/gsfonts/n022004l.pfb: Nimbus Mono L:style=Bold
/usr/share/fonts/type1/gsfonts/n019024l.pfb: Nimbus Sans L:style=Bold Italic
/usr/share/fonts/type1/gsfonts/b018032l.pfb: URW Bookman L:style=Light Italic
/usr/share/fonts/type1/gsfonts/p052003l.pfb: URW Palladio L:style=Roman
/usr/share/fonts/type1/gsfonts/n019004l.pfb: Nimbus Sans L:style=Bold
/usr/share/fonts/type1/gsfonts/b018015l.pfb: URW Bookman L:style=Demi Bold
/usr/share/fonts/type1/gsfonts/n022024l.pfb: Nimbus Mono L:style=Bold Oblique
/usr/share/fonts/type1/gsfonts/c059036l.pfb: Century Schoolbook L:style=Bold Italic
/usr/share/fonts/type1/gsfonts/p052024l.pfb: URW Palladio L:style=Bold Italic
/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book
/usr/share/fonts/type1/gsfonts/n019003l.pfb: Nimbus Sans L:style=Regular

@yuanwliu.

Yes, that is the issue. Have you copied the following fonts to any self created and accessible directory in your Linux and then tried accessing that directory externally. The idea of using LoadExternal fonts is that there may be some fonts used in presentation that are not available or installed on you target machine. So, you just create a custom directory on target machine and copy the unavailable/Uninstalled used fonts externally there. Then you load the fonts in your application just before loading the presentation as mentioned in code sample shared. I hope this should work.

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