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!