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
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:
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.
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.
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.
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>
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.