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

Free Support Forum - aspose.com

Background Image Disappears when Saving to PDF

I have an asp.net web application that adds a background image to a workbook’s worksheets then saves the workbook to the Response.OutputStreem as a pdf document. When I do this the background image doesn’t get saved with the pdf. When I change the SaveFormat to Excel97To2003 the background image is correctly displayed in the downloaded file. Here’s the code I’m using to add the background image and save the pdf to the Response.OutputStream:


Workbook wb = new Workbook(memoryStream);
if (!string.IsNullOrWhiteSpace(BackgroundImage))
{
FileStream fs = File.OpenRead(Page.Server.MapPath(BackgroundImage));
byte[] imageData = new byte[fs.Length];
fs.Read(imageData, 0, imageData.Length);

foreach (Worksheet worksheet in wb.Worksheets)
{
worksheet.SetBackground(imageData);
}
}

wb.Save(Page.Response.OutputStream, SaveFormat.Pdf);

Thanks for any help!

Hi,


The reason is pretty simple, if you could take the print preview of a sheet with background image set in MS Excel, you will see it does not show either. So, the generated PDF file rendered by Aspose.Cells for .NET cannot support it. By the way, the background image set for the worksheet is only for working in MS Excel environment, even if you take the print of the Excel sheet in MS Excel, it will not render/print.

Thanks for your understanding!