Hi, I have tried following code to add EMF image into the PDF page using Aspose.Slides but the final output pdf the image seems to be raster-based rather than the original vector based emf image.
By default, Aspose.Slides converts vector images to raster images when converting PowerPoint presentations to PDF documents.You can use the PdfOptions class to specify whether vector images should be preserved in exported PDF files as is. The following code example shows you how to do this:
auto pdfOptions = MakeObject<PdfOptions>();
pdfOptions->set_SaveMetafilesAsPng(false);
pres->Save(outputFilePath, Export::SaveFormat::Pdf, pdfOptions);
pres->Dispose();
Thank you, could you please help with the header class to include for “Pdfoptions” in C++?
I tried to “#include <Export/IPdfOptions.h>” but its says cannot instantiate abstract class
Thank you, that worked for me. Just want to clarify will there be any performance issues printing 20-30 EMF images in single page and creating 30–40-page vector-based PDF? If so than how can I optimize it?
@ashvek,
No, there shouldn’t be any performance issues when printing 20-30 EMF images on a single page and creating a 30–40-page vector-based PDF. EMF files are vector images, which typically take up less space compared to raster images, making them more suitable for multi-page PDF documents. However, it’s always a good idea to test with actual data to confirm this. Please let us know if performance does become an issue.
Thank you, sure we will get in touch if we face any issues. Just one more thing to clarify is for this test code I have used “File::ReadAllBytes(emfFilePath1)” from IImageCollection | Aspose.Slides for C++ API Reference
String emfFilePath1 = _filePath + u"DPV3070.emf";
auto image1 = pres->get_Images()->AddImage(File::ReadAllBytes(emfFilePath1));
Is this the optimized way of reading file in slides or I have to use different API among Iimagecollection?
@ashvek,
This is the correct way to add the image to the presentation resources. You can also look at methods for adding images with other parameters that may be useful to you, particularly methods to which streams are passed.