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

Free Support Forum - aspose.com

Workbook.Save: location of temp files

I have a workbook that I save into a stream (to later save it as a .PDF). This workbook as a bitmap in it.

When I use:

Dim stream As IO.MemoryStream = New IO.MemoryStream

pWorkBook.Save(stream, FileFormatType.AsposePdf)

I see a file named tmpFile.tmp_img0.jpg in my temp folder.

Is there a way to:

  • Not having this file?
  • or automatically delete it when no more required?
  • or specify a folder to save it?

I have another workbook that saves a lot of .emf files (2010751070tmpFile.tmp_img0.emf).


  • or specify a folder to save it?

I think you may change your code and try to save the .xml file to disk in your specified folder (as shown below). The images are automatically saved in the same folder where your .xml file is saved.

pWorkBook.Save(strFilePath, FileFormatType.AsposePdf) 'where strFilePath is a variable that stores the .xml file path e.g.., ...\MyFolder\myfile.xml

Thank you.

But I use a memory stream. Isn’t stream faster then file?


Well, it does not have any significant difference related speed. Anyways, since you are using memory streams so the images would be stored in the \Temp folder, I think you can delete those images using Aspose.Pdf API automatically, check and try the following line in your code:

pdf.IsImagesInXmlDeleteNeeded = True

Thank you.


The "pdf.IsImagesInXmlDeleteNeeded = True" statement helps in 1 of my 2 scenarios (and as no impact on the other).

When I step through code to debug, I see a file named tmpFile.tmp_img0.jpg in my temp folder and it automatically disappear as soon as pdf1.Save is executed.

In the other scenario, I open an existing workbook from which I hide (ws.IsVisible = False) worksheets that are not required. I then save the workbook to a memory stream which I then Bind and save in a PDF document. In this scenario, I see about 10 .emf files (like 2010751070tmpFile.tmp_img0.emf) and they are not deleted even if I have the "pdf.IsImagesInXmlDeleteNeeded = True" statement.

Any other ideas?


Well, is it not better to post this issue to Aspose.Pdf team for the API ("pdf.IsImagesInXmlDeleteNeeded = True") you are using is related to Aspose.Pdf for .NET. The Aspose.Pdf team might help you resolving this issue.

Alternatively, I think you may try to delete those unwanted worksheets (using Worksheets.RemoveAt() method) before rendering to .pdf file and check if it works fine for your requirement.

Thank you.

I have tried the RemoveAt and it is working just as well (provides the same results). Is there any advantages of this method over setting the IsVisible to False?

I will post a new question to the Pdf team and will see.

I have created a question in the Aspose.PDF forum (

objWorkbook.Save(ms, Aspose.Cells.FileFormatType.AsposePdf)

If the Save method of the Workbook object generates all those unwanted files, then it should be you that could fix the problem!


Thanks for further details,

We will look into it soon from our side.

Thank you.


If the worksheet is not visible, we do not convert that worksheet to pdf. But we export the picture files in the worksheet. We will check it and fix it.Thanks for your patience.


Please try the fix in <A href="</A>.</P> <P>We do not export the image or chart if the worksheet is not visible or the image/ shape is not in the print area.</P>


It seems to work. I don't see tons of .emf into the temp folder now.

What if an image is in a visible worksheet? Can we direct the work files in another folder or are they automatically deleted when the process is done?


I just made the test with a visible worksheet. I see that the .emf/.bmp files are created and they are automatically deleted when the process is complete.