We are using the following code to convert EMF to PDF:
In most case, it works perfectly.(2000 - 3000 lines)
But when the EMF contain a lot of sharps(4000 - 6000 lines), it throw exception at the CacheData().
I search this forum and found a similar topic, but I still encounter this problem after I upgraded Imaging to the latest version.
private void EmfToPdf(MemoryStream msEmf, Stream outStream)
{
msEmf.Seek(0, SeekOrigin.Begin);
using (var img = Aspose.Imaging.Image.Load(msEmf) as Aspose.Imaging.FileFormats.Emf.EmfImage)
{
img.CacheData();
var emfRasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions
{
BackgroundColor = Aspose.Imaging.Color.White,
PageSize = img.SizeF,
RenderMode = Aspose.Imaging.FileFormats.Emf.EmfRenderMode.EmfOnly
};
var pdfOptions = new Aspose.Imaging.ImageOptions.PdfOptions
{
VectorRasterizationOptions = emfRasterizationOptions
};
// save in different formats
img.Save(outStream, pdfOptions);
}
}