We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert Excel to pdf with images

I am trying to convert and excel workbook to pdf using Aspose.Cells and Aspose.Pdf.

One problem i have encountered is images in the excel workbook are not coming thru in the pdf.

I checked the xml file i generated from Aspose.Cells to use with Aspose.Pdf, and i noticed that there were no images elements in xml.

So, i thought could around this problem by opening the excel workbook with Aspose.Cells, and scanning the workbook for images. i would record the image, size, location and sheet that it is on.
I would then save all the images to the harddrive and edit the xml just before Aspose.Pdf gets it to include the appropriate elements so that images would be included.

Unfortunately, i cannot find a way to extract the images from the workbook, how can i do this?

Also, is it a bug that images are not supported in the excel to pdf conversion?

Ivan.

Hi Ivan,

Image is not supported in xls2pdf conversion. We will make this feature in the next few months.

ok, thanks for that.

is there any way to extract images from the excel worksheets?

Not supported yet. But we are working on this feature.

Its the same case for CHARTS and I was told they will be supported in xls2pdf by end of December. Is it still true?

To convert chart in xls2pdf, we have to make chart2image conversion first. That delayed our schedule for these features to Q1 2007.

Aspose.Cells has supported the feature, i.e., convert the Excel Charts to images and PDF formats without requiring any additional tools or applications. The feature has become more robust and efficient. In order to provide rendering support, the Chart class has exposed ToImage & ToPdf methods with a verity of overloads to best suit the application requirements.

See the following sample code for your reference:
e.g
Sample code:

// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a new worksheet to the Workbook
int sheetIndex = workbook.Worksheets.Add();
// Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection
Worksheet worksheet = workbook.Worksheets[sheetIndex];

// Adding sample values to cells
worksheet.Cells["A1"].PutValue(50);
worksheet.Cells["A2"].PutValue(100);
worksheet.Cells["A3"].PutValue(150);
worksheet.Cells["B1"].PutValue(4);
worksheet.Cells["B2"].PutValue(20);
worksheet.Cells["B3"].PutValue(50);

// Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
// Accessing the instance of the newly added chart
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
// Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);

// Create an instance of ImageOrPrintOptions and set a few properties
ImageOrPrintOptions options = new ImageOrPrintOptions()
{
    VerticalResolution = 300,
    HorizontalResolution = 300,
    SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
};
// Convert chart to image with additional settings
chart.ToImage("chartPNG_out.png", options);

See the document for your further reference:
https://docs.aspose.com/display/cellsnet/Chart+Rendering

You may also download the up-to-date examples/demos here.

Hope, this helps a bit.