I have been creating doc files from HTML, and the images are added successfully. However, there is one image that I need to remain as an external link, so that it is not embedded in the document, and when the document is opened the image is rendered at that time. Is this possible?
Just to ensure we are on the same page, would you please share a sample Word document that contains an external link to an image that is rendered when the document is open.
Hello, I am attaching an example of what I mean (the image doesn’t display, but it is sufficient for demonstration purposes). example.doc.zip (6.8 KB)
Using Word 2016, I added the image as an object, clicked the “Create from File” tab, entered the URL and selected the option to Link as File. This means that the image is not stored in the document, but a reference to the location is. Adding an image this way is different from embedding it, since the image could change in the source location at any time, and updates would be displayed in the document without further editing. Here is a description of the feature I am looking for: Insert an object in Word or Outlook - Microsoft Support
Thank you for explaining the requirement in detail.
Unfortunately, at present Aspose.Words REST APIs are not providing this feature. I have logged a request in our internal tracking software (WORDSCLOUD-360) for the implementation of this feature. I will update you here once I have an input of our Development Team.
Since an HTML file does not contain any clue that the particular image should not be embedded so you need to do following:
Convert HTML file to Doc
Remove the image that you want to appear as an external link
Add a field as explained below:
Insert a new field using Aspose.Words for Cloud PutFieldRequest API
Field body = new Field { FieldCode = "{ INCLUDEPICTURE \"https://i.artfile.me/wallpaper/08-12-2015/1920x1080/priroda-zima-sneg-vecher-derevya-izgorod-994285.jpg\" \\d }" };
var request = new PutFieldRequest("SampleWordDocument.docx", body, FOLDER, destFileName: "TestPutField.docx");
var actual = this.wordsApi.PutField(request);
Hope this helps. For more examples regarding Fields, please check the SDK.