How to convert PPTX file contain images to PDF in .NET

Hi All,

Our team now facing an error when trying to convert pptx file contain some picture (attached file) to pdf for previewing, could you please give us some advice, below is the information regrading this error:

  • Aspose version we are using have SubscriptionExpiry on 2015/11/07
    Apose.Pdf version : 10.9.0
    Apose.Slides .NET version : 15.9.0

  • C# code : Exception from this block of code
    using (var ms = new MemoryStream(binary))
    {
    var amaDocType = Aspose.DocumentTypeManager.GetType(@this.Label);
    //This one crach if cannot preview
    Preview.PageCount(ms, amaDocType); <-- Error
    return true;
    }

  • Exception message :
    {Aspose.Slides.PptxReadException: Parameter is not valid. —> System.ArgumentException: Parameter is not valid.
    at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
    at Aspose.Slides.ImageCollection.AddImage(MemoryStream stream)
    at Aspose.Slides.ImageCollection.AddImage(Byte[] buffer)
    at .( )
    at .( )
    at .( , IPresentation )
    at .(Presentation , Stream )
    — End of inner exception stack trace —
    at .(Presentation , Stream )
    at Aspose.Slides.Presentation.(Stream )
    at Aspose.Slides.Presentation.(Stream )
    at Aspose.Slides.Presentation…ctor(Stream stream, LoadOptions loadOptions)
    at Amaris.Aspose.Preview.PreviewPowerpoint.get_Presentation()
    at Amaris.Aspose.Preview.PreviewPowerpoint.PageCount()
    at Amaris.Document.WepApp.Extensions.DocumentExtensions.IsPreviewable(AmarisDocument this, Byte[] binary) in
    TestFile.zip (32.2 KB)

@VoVanHai,

I have worked with source file shared by you using Aspose.Slides for .NET 19.5 and unable to observe any issue. I have also shared my generated result with you for your kind reference. Please check attachment. Can you please try to use latest version on your end.
TestFile.pdf (26.7 KB)

thank for your help Admad, we are conserding to replace Aspose Total .Net to GroupDocs Total .Net so we have a few question regarding that. For now, we are using Apose for previewing image, pdf, MS Office, signing document (add signature image to pdf file), etc. Do you think Groupdocs can replace Aspose for those kind of behaviors or which one better for our case. thanks

@VoVanHai,

I have observed your requirements related to Aspose.Groupdocs and moving this to concerned forum where our respective support team will assist you further.

@vovanhai,

Yes, you can use GroupDocs APIs for previewing as well as signing the documents. In your case, GroupDocs.Viewer for .NET will be used to generate the previews for all the document formats that you have mentioned above, whereas, GroupDocs.Signature for .NET will serve you for the signing the PDF documents.

GroupDocs.Viewer provides two modes to render the documents - HTML based rendering and Image-based rendering. Furthermore, it also allows you to render the document as a PDF file. As a reference, please have a look at the following documentation articles that contains the details along with the code samples.

And to know about how to add image signature to the PDF documents, please consult this article.

Last but not least, you can download the following example projects to evaluate all the features offered by GroupDocs.Viewer for .NET and GroupDocs.Signature for .NET.

Thank you very muck for your help Aziz, we are now comparing Groupdocs and Aspose with some criteria but most focus on performance with big file, I got a temporary license for Groupdocs from your company sale department but unfortunately, when I’m trying to convert example with Doc file to Image the output is just 2 first page converted ( I already apply the license ), there is any way to have no limited license to do testing with i think just need for 1 week. thanks

@VoVanHai,

The temporary license is actually a full license that is valid for 30 days and you can evaluate all the API features without any limitations. However, in case the license is not applied properly, the API processes the first two pages only and the output contains the evaluation watermark at the top of each page. First of all, I would recommend you to cross-check the following:

  • Double check that your application has access to the location where the license file is placed and also, the current user with whom the application is being accessed has permissions to that location/path.
  • Make sure the input document contains more than 2 pages and the pages do not already have the evaluation message.
  • Check if your code does not catch an exception thrown by API’s licensing code.
  • Clear GroupDocs.Viewer’s cache folder and try again.

In case the issue persists, please share with us your license file via private message (see how to send a private message). Furthermore, please also share with us the sample application as well as the doc file that you are using to render as image.

@usman.aziz,
Now we have evaluation result for GroupDocs and Aspose and wait for the decision from manager, thank you so much for your help.

1 Like

@VoVanHai,

You are always welcome.