Hi,
We’re using Aspose.Slides for Java version 2.7.0 in one of our applications and we’re experiencing a couple of different errors when that application is hosted on different platforms.
When hosted on a debian server, text in images extracted from PPTX files is coming out distorted or in completely the wrong location on the slide. See the attached example slideImage.png which was extracted from the attached 2479_1.pptx file using the following code:
…
FileInputStream fis = new FileInputStream(presentationFile);
PresentationEx presentation = new PresentationEx(fis);
SlideEx slide = presentation.getSlides().get(slideNumber);
BufferedImage bimage = this.getScaledJpgFromSlideEx(slide, height, width, maintainAspectRatio);
fis.close();
return bimage;
…
private BufferedImage getScaledJpgFromSlideEx(SlideEx slide, int height, int width,
boolean maintainAspectRatio)
{
// Get the image at the original size
BufferedImage image = slide.getThumbnail(1f, 1f);
if (maintainAspectRatio)
{
Dimension slideSize = slide.getParent().getSlideSize().getSize();
// -1 is how the aspect ratio is maintained
if (slideSize.getWidth() > slideSize.getHeight())
{
height = -1;
}
else
{
width = -1;
}
}
Image resizedImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage bufferedThumbnail = new BufferedImage(
resizedImage.getWidth(null),
resizedImage.getHeight(null),
BufferedImage.TYPE_INT_RGB);
bufferedThumbnail.getGraphics().drawImage(resizedImage, 0, 0, null);
bufferedThumbnail.flush();
return bufferedThumbnail;
}
Weirdly on a windows server the images extracted from the same PPTX file are correct with no problem in the text size or placement.
However, when we merge more than one presentation together on the windows server then open the result in PowerPoint 2010 we get the following message after enabling editing:
"PowerPoint found content in merge.pptx that it did not understand. This content has been removed and cannot be recovered. You should review this presentation to determine whether any content was unexpectedly changed or removed"
The file merge.pptx is attached to this message and was generated with the following code:
private void mergePPTXs(List pptxFiles, File resultFile) throws FileNotFoundException,
IOException
{
PresentationEx presentation = new PresentationEx();
SlidesEx destSlides = presentation.getSlides();
for (File file : pptxFiles)
{
if (checkPPTX(file))
{
// This file to be included in the download is a PPTX file itself.
// So, add all the slides from this to the end of the download PPTX we are creating:
PresentationEx srcPres = new PresentationEx(new FileInputStream(file));
SlidesEx slides = srcPres.getSlides();
for (int i = 0; i < slides.size(); i++)
{
// Clone the desired slide from the source PPTX to the end of the collection
// of slides in the destination PPTX
destSlides.addClone(slides.get(i));
}
}
}
// Remove empty slide
presentation.getSlides().remove(0);
// Creating a file output stream to write the output file
FileOutputStream fostream = new FileOutputStream(resultFile);
// Writing the presentation as a PPTX file
presentation.write(fostream);
// Closing the streams
fostream.close();
}
If anyone has any suggestions about how to get round either of these two problems it would be a great help.
Thanks,
Matt