Image added using Place in cell option removed when converted to PDF

Steps:

  1. Open a blank excel file
  2. Click the Insert tab
  3. Click on Pictures
  4. Click Place In Cell
  5. Browse an image from your PC and add it into any cell
  6. In another part of the excel, just copy paste an image

When this excel (Test Document.zip (1.2 MB)) is exported using the below code. The Image added using Place in Cell is missing. But the one that is copied in as a floating image, is still in the PDF.
Test Document.pdf (1.0 MB)

Code to Convert to PDF(Generic Code):
Aspose.Cells Version: 17.1.12.0
using (var doc = new Workbook(Stream))
{
var converted = new MemoryStream();
doc.Save(converted, new PdfSaveOptions { ImageType = ImageFormat.Png });
converted.Seek(0, SeekOrigin.Begin);
return new FileContent
{
Stream = converted,
FileName = Path.ChangeExtension(FileName, “.pdf”),
ContentType = PdfContentType
};
}

Is this issue/feature is handled in latest release of Aspose.Cells?

@yogeshRamani

Cause

The issue you’re encountering, where images added using the “Place in Cell” option in Excel are missing after conversion to PDF, is likely due to the version of Aspose.Cells you are using (17.1.12.0). This version may not fully support the handling of images placed within cells, especially when exporting to PDF.

Solution

To resolve this issue, I recommend upgrading to the latest version of Aspose.Cells. Newer versions often include bug fixes and enhancements that improve compatibility with various Excel features, including image handling.

Code

Here’s a sample code snippet to convert an Excel file to PDF using the latest version of Aspose.Cells:

using Aspose.Cells;
using System.IO;

public FileContent ConvertExcelToPdf(Stream excelStream, string fileName)
{
    using (var workbook = new Workbook(excelStream))
    {
        var pdfSaveOptions = new PdfSaveOptions
        {
            ImageType = ImageFormat.Png,
            Compliance = PdfCompliance.PdfA1b // Adjust compliance as needed
        };

        var convertedStream = new MemoryStream();
        workbook.Save(convertedStream, pdfSaveOptions);
        convertedStream.Seek(0, SeekOrigin.Begin);

        return new FileContent
        {
            Stream = convertedStream,
            FileName = Path.ChangeExtension(fileName, ".pdf"),
            ContentType = "application/pdf"
        };
    }
}

Next Steps

  1. Upgrade to the latest version of Aspose.Cells from the Aspose website.
  2. Test the conversion again using the provided code snippet.
  3. If the issue persists, please share the updated code and any error messages you encounter.

Please let me know if you need further assistance or if this resolves your issue!

@yogeshRamani,

Thanks for the sample files and details.

Rendering place in cell pictures in Excel to PDF conversion is new feature and has been supported in newer versions of the APIs. I have tested using your template XLSX file to convert to PDF via Aspose.Cells for .NET v25.7 and it works fine and as expected. The images (placed in cells) are rendered fine into the output PDF. So, please upgrade to and try latest version of the API (e.g., Aspose.Cells for .NET v25.7) for the task.

@amjad.sahi ,

Thanks for your input. It worked with the latest version.

@yogeshRamani
Thank you for your feedback. You are welcome. I’m glad you solved the issue with the latest version. If you have any questions, please feel free to contact us at any time.