Free Support Forum - aspose.com

Unable to convert presentations containing EMF images to PDF using Presentation.SaveToPdf()

Hi. I am reposting this message that I have yet to receive a reply on, which I originally posted 4 days ago under a different but related thread. This issue is very important to my evaluation of Aspose.Slides, so any reply would be helpful…even just a message that it’s being looked into.

I’m evaluating Aspose.Slides for .Net and using version 2.8.4.0.

We
use EMF images of charts in our presentations. We have found that
using a vector format such as this is absolutely essential to having
high quality images for printing while retaining reasonable file sizes.

The
PowerPoints we create using Aspose show the EMF format fine and look
great. However, when we call Presentation.SaveToPdf(System.IO.Stream),
it appears that the EMF format images are being converted into very low
quality images before they are added to the PDF. This is not a
limitation of PDF, because if we manually use Acrobat to convert the
same PowerPoint to PDF, the images are embedded as EMF format.

What
is important to us is using some sort of vector format image, not EMF
specifically, so I tried SVG. This led to the exception:

System.ArgumentException
Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at Aspose.Slides.PPImage…ctor(Presentation parent, Stream stream, Boolean close_stream)
at Aspose.Slides.Picture…ctor(Presentation parent, Stream stream)

at
WorkplaceDynamics.Results.Presenting.Summaries.insertFactorStatementsHeatMap(User
user, Int32 surveyEventId, Factor factor, Shape shape) in
C:\VersionControl\Applications\Results\Trunk\WorkplaceDynamics.Results.Presenting\Summaries.cs:line
150
at
WorkplaceDynamics.Results.Presenting.Summaries.customizeSlide(User
user, Int32 surveyEventId, Slide slide, Factor topFactor, Factor
bottomFactor) in
C:\VersionControl\Applications\Results\Trunk\WorkplaceDynamics.Results.Presenting\Summaries.cs:line
62
at
WorkplaceDynamics.Results.Presenting.Summaries.customizePresentation(User
user, Int32 surveyEventId, Presentation presentation) in
C:\VersionControl\Applications\Results\Trunk\WorkplaceDynamics.Results.Presenting\Summaries.cs:line
44
at
WorkplaceDynamics.Results.Presenting.Summaries.WriteSummaryToStream(Stream
stream, User user, Int32 surveyEventId, String templateDirectory,
Boolean isPdf) in
C:\VersionControl\Applications\Results\Trunk\WorkplaceDynamics.Results.Presenting\Summaries.cs:line
23
at
WorkplaceDynamics.Results.UI.Summary.ProcessRequest(HttpContext
context) in
C:\VersionControl\Applications\Results\Trunk\WorkplaceDynamics.Results.UI\Summary.ashx.cs:line
32
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Getting
the exception isn’t surprising, as Microsoft products typically have
better support for EMF than for SVG, but the stack trace suggests one
possible explanation for the EMF issue. System.Drawing.Image does not
natively support saving EMF files.

The Microsoft documentation (http://msdn.microsoft.com/en-us/library/ktx83wah.aspx) indicates:
If no encoder exists for the file format of the image, the Portable Network Graphics (PNG) encoder is used. When you use the Save
method to save a graphic image as a Windows Metafile Format (WMF) or
Enhanced Metafile Format (EMF) file, the resulting file is saved as a
Portable Network Graphics (PNG) file. This behavior occurs because the
GDI+ component of the .NET Framework does not have an encoder that you
can use to save files as .wmf or .emf files.
This sounds a lot like what is happening when the PowerPoint is saved to PDF using SaveToPdf()

So
with all that said, is there any way that I can use Aspose to save a
dynamically created PowerPoint that contains EMF images to a PDF that
retains the high quality of the EMF images?

Not being able to do this makes the output so unprofessional looking that we will not be able to use the product.

We
would be willing to buy both Aspose.Slides and Aspose.PDF if that’s
what it took, but I don’t see any mention of the PowerPoint format in
the Aspose.PDF marketing pages on the web site.

Thank you very much for your help!

Rick

Hello Rick,

If I’m not mistaken, PDF specification doesn’t allow inserting any metafiles. Aspose.Slides converts metafiles to PNG images and after that put it to PDF page. Most probably Acrobat parse metafiles and insert it as set of shapes instead of real wmf/emf stream.

SVG exporter also converts metafiles to PNG.
One more thing you should know is our PDF exporter uses SVG as intermediate format.

Thanks for your quick reply!

Can you confirm that my understanding is correct…there is no way to use Aspose products to achieve my goal of converting a PowerPoint presentation containing EMFs to a PDF while retaining the resolution independent nature of the EMFs in the PDF?

Yes, you are right, currently there is no way to convert metafiles to PDF’s vector graphics.
May be it will be available in the future after implementing of a new rendering engine.