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

Free Support Forum - aspose.com

ExportEmbeddedImages dont work as epected

Hi,

I want to convert a document to an html file and export the images to the same folder.

I set ExportEmbeddedImages = true and ResourcesFolder=""

The images have been exported but the files are stored in a subfolder which has the same
name like the html file.

How can export the images to the same folder like the html file ?
And how can I make sure that the URL link in html file is relative (image001.png) and not absolute (c:\image001.png) ?

Kind regards,
Guido

@Nachti

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi Tahir,

here is the document
image.zip (2.0 MB)

this is the code:

Document docWR = new Document(@"image.docx");
HtmlFixedSaveOptions saveOptionsFixed = new HtmlFixedSaveOptions();
saveOptionsFixed.ResourcesFolder = "";

docWR.Save(@"C:\Temp\Image.html", saveOptionsFixed);

The HTML file will be created at C:\Temp\image.html but the images are not
located in the same folder as expected but in a sub folder with the name ‘image’.

If you look at the HTML, the URL of the image relates to image/image001.png.

I have checked the API docu: api docu

‘If you save a document into a file and provide a file name, Aspose.Words, by default, saves the images in the same folder where the document file is saved.’

How can set it up to save it in the same folder ?

Kind regards,
Guido

@Nachti

We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22538. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@Nachti

Please use the following code example to get the desired output. Hope this helps you.

var MyDir = @"C:\temp\";
Document docWR = new Document(MyDir + "image.docx");
HtmlFixedSaveOptions saveOptionsFixed = new HtmlFixedSaveOptions();
saveOptionsFixed.ResourcesFolder = MyDir; 
saveOptionsFixed.ResourcesFolderAlias = "./"; 
saveOptionsFixed.PrettyFormat = true;
docWR.Save(MyDir + @"21.7.html", saveOptionsFixed);