When I convert HTML into WORD by using InserHtml method, Images get downloaded in the specified directory. But they get names like Aspose.Words.cc43531a-…-02818234c544.007.jpeg…
Is there a way we can specify prefix or postfix to images while specifying ExportImagesFolder?
OR Can we get the image names from document? when we extract images, I am not able to get Image names out of Shape. SourceFullName and title is empty string.
My problem is, I need to delete the images that belong to perticular user.
Thanks.
Hi,
Yes, image file names are composed in accordance with this template and we had no reason to alter this behaviour so far. But this happens when you export the document to HTML; when you insert HTML into the document, Aspose.Words just inserts image bytes and that’s it. You seem to have mixed up these two scenarios. Correct me if I’m wrong.
Also, I don’t fully understand what names you want to extract. Are those original image file names? As I mentioned above, Aspose.Words embeds images when importing HTML and does not preserve any information about the source files; AFAIK MS Word does the same. Please clarify this point.
I want to get the filenames composed, like Aspose.Words.cc43531a-…-02818234c544.007.jpeg…
Multiple user will use Aspose word functionality and all those images will be saved in one folder. I want to search aspose word document for all the images for that user and delete it when I am done with it. I can’t delete all the files in the folder(that I mentioned while setting ExportImagesFolder property), as they may be of different users.
Or is there any other way to do it?
I am sorry for being slow today, but I’m still trying to get the idea. You state that many users will use Aspose.Words functionality, does that mean the export of the document will be repeated? Is it suitable to specify different ExportImagesFolder for different users then?
Yes. That’s what I’ll have to do if I don’t find any other way. But I am not very keen about that. In the application we have Export facility. Suppose at the same time 2 users tried to export doc. then their images will be saved in one folder. then I just can’t delete all the images in folder when first user finishes his downloading, as another user may still need his images. There must be some way to find the images saved to delete…I can extract images from document but only if I can find their names to delete it one by one for that user will be good…
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true, false);
foreach (Aspose.Words.Drawing.Shape shape in shapes)
{
if (shape.HasImage)
{
// If I can get names of images here..Here ImageData.SourceFullName should return the name/path of file.But it's empty.
string imageFileName = string.Format("Image.ExportImages.{0} Out.{1}", imageIndex, shape.ImageData.ImageType);
arraylist.Add(imageFileName);
imageIndex++;
}
}
SourceFullName is not empty for linked (not embedded) images only. Thank you for explanation, I understand that if you were able to specify image file name prefix or postfix, you could have easily determined the “owner” of particular images and delete them when needed. However, there is no way to store image file names together with embedded images and I still have no idea why you would need that. Do you have many documents? In this case, prefix or postfix would also help… Anyway, I have logged your request as issue #1559 and we will consider it later.
The issues you have found earlier (filed as 1559) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by alexey.noskov.
Hello!
Thank you for your patience. In the latest release we have implemented a new feature that allows you control how output supplementary images are named.
To alter file names please implement a handler of this event:
https://reference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/imagesavingcallback/
In particular, you can build up a new name analyzing CurrentShape.ImageData.Title, CurrentShape.ImageData.SourceFullName, CurrentShape.Name and name generated by default. Note that some or all name-related shape properties can be empty in the model for a particular image. And this shouldn’t break your naming algorithm.
You can also specify folder where to save all images and folder alias, the base URI to refer files in the output HTML. Now this is available while saving either to a file or to a stream. See these properties:
https://reference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/imagesfolder/
https://reference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/imagesfolderalias/
ExportImagesFolder is now considered obsolete. Please use HtmlExportImagesFolder instead.
Here is the latest version, Aspose.Words 6.1.0:
https://releases.aspose.com/words/net
Regards,