Image file is getting attached to aspnet worker process

Hi We are creating a PDF using aspose.cells.

Following is the code.

----------------------------------------------------------------------------------------------workBook.Open(Server.MapPath(@"Upload\")+"GapChartReport.xls");

workBook.Save(Server.MapPath(@"Upload\")+lstrPDfFilename+".xml", FileFormatType.AsposePdf);

pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(Server.MapPath(@"Upload\")+lstrPDfFilename+".xml", null);
----------------------------------------------------------------------------------------

The excel file (GapChartReport.xls) is having an image in the footer. Which we have inserted through code. Here it is...

---------------------------------------------------------

body { margin: 0 0 0 0; padding:0 0 0 0 } td,div { font-family:Tahoma;font-size:8pt;vertical-align:top } body { margin: 0 0 0 0; padding:0 0 0 0 } .transcript { background-color:#d2d2d2; } .messageBlock { margin-left:4px; margin-bottom:3px } .message { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; } .messageCont { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;} .other { color:#39577a;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .myself { color:#da8103;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont { font-size:8px;text-align:right; color:#39577a;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .myselfCont { font-size:8px;text-align:right; color:#da8103;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .system { margin-left:4px; word-wrap:break-word;color:#da8103;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre; } .showTimestamp { margin-right:3px; float:right; color:#999999;font-style:normal;font-weight:normal; } .other1 { color:#ac2000;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont1 { font-size:8px;text-align:right; color:#ac2000;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other2 { color:#3c9fa8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont2 { font-size:8px;text-align:right; color:#3c9fa8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other3 { color:#e25614;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont3 { font-size:8px;text-align:right; color:#e25614;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other4 { color:#0b6ac8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont4 { font-size:8px;text-align:right; color:#0b6ac8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other5 { color:#b23290;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont5 { font-size:8px;text-align:right; color:#b23290;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other6 { color:#02e7c7;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont6 { font-size:8px;text-align:right; color:#02e7c7;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other7 { color:#5b3284;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont7 { font-size:8px;text-align:right; color:#5b3284;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .tsDisplay { display:block }

ogo_url = logo_url + "imgFooter.jpg";

//Declaring a FileStream object

FileStream inFile;

//Declaring a byte array

byte[] binaryData;

//Creating the instance of the FileStream object to open the logo/picture in the stream

inFile = new System.IO.FileStream(logo_url, System.IO.FileMode.Open, System.IO.FileAccess.Read);

//Instantiating the byte array of FileStream object's size

binaryData = new Byte[inFile.Length];

//Reads a block of bytes from the stream and writes data in a given buffer of byte array.

long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length);

//Setting the logo/picture in the central section of the page header

workSheet.PageSetup.SetFooterPicture(0, binaryData);


//Setting the script for the logo/picture

workSheet.PageSetup.SetFooter(0, "&G");

---------------------------------------------------------

While creating the pdf aspose created a new image file and saved it into the same folder.

This new image file is getting attched to the aspnet_wp (worker process) and we are not able to delete it. We always have to kill the worker process before deleting the image file.

So first time when we create PDF we are able to generate it. But next time onwords when we create PDF again we get following error.

"the process cannot access the file it is being used by another process".

Please suggest what needs to be done in this case.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please try the direct Xls2Pdf conversion using Aspose.Cells. Please see the following documentation link for details and sample code.

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/converting-to-pdf-files.html

Thank You & Best Regards,