We are actively evaluating the ASPOSE.TOTAL and interested in purchasing OEM version of it. We have built our PoC solution using the component, but we are facing an issue in converting some PPTX. Can someone help us or direct us to someone who can analyze the issue?
Attached is the PPTX in question. First 2 pages in PNG contains no text. We tried with system default font as well as custom (gulim) one, but result is the same.
Please help. We have a tight timeline to make go, no-go decision with ASPOSE.
Code
---
using Aspose.Slides;
using Meerue.Converter;
using Meerue.Converter.Message;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
namespace Meerue.OfficeConverter.Slide
{
public class SlideConverter : BaseConverter, IConverter
{
private const string DEFAUlT_FONT = "gulim";
private static SlideConverter instance;
private SlideConverter()
{
Initialize();
}
public static SlideConverter Instance
{
get
{
if (instance == null)
instance = new SlideConverter();
return instance;
}
}
public void Initialize()
{
License lic = new License();
lic.SetLicense("Aspose.Total.lic");
// Load private font.
PrivateFontCollection fontCollection = new PrivateFontCollection();
fontCollection.AddFontFile(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "gulim.ttc"));
}
public IEnumerable Convert(Stream source, ConvertOption option)
{
source.Position = 0;
var loadOpt = new LoadOptions(LoadFormat.Auto)
{
DefaultAsianFont = DEFAUlT_FONT,
DefaultRegularFont = DEFAUlT_FONT,
DefaultSymbolFont = DEFAUlT_FONT,
OnlyLoadDocumentProperties = true,
};
using (Presentation pres = new Presentation(source, loadOpt))
{
var orderedRange = GetPageRanges(pres.Slides.Count, option);
// Save each page of the document as Png.
foreach (var seq in orderedRange)
{
// can not convert to png directly.
ISlide slide = pres.Slides[seq];
//// check textFrame.
//foreach (IShape shp in slide.Shapes)
//{
// if (shp.Placeholder != null)
// Console.WriteLine(((IAutoShape)shp).TextFrame.Text);
//}
var sizeF = GetSizeF(option.ConvertQuality, pres.SlideSize.Size);
Bitmap bmp = slide.GetThumbnail(sizeF.Width, sizeF.Height);
Stream stream = new MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
yield return new ConvertResult(seq, stream);
}
}
source.Close();
}
public void HandleConvertFail(System.Exception ex, ConvertOption option)
{
throw new System.NotImplementedException();
}
private SizeF GetSizeF(Quality quality, SizeF slideSize)
{
//Getting scaled value of X and Y
float ScaleX = (float)(1.0 / slideSize.Width) * (5 / (int)quality);
float ScaleY = (float)(1.0 / slideSize.Height) * (5 / (int)quality);
ScaleX = (float)(int)quality / 5;
ScaleY = (float)(int)quality / 5;
Console.WriteLine(ScaleX.ToString() + ":" + ScaleY.ToString());
return new SizeF(ScaleX, ScaleY);
}
}
}