Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for your thoughtful feedback.
I think that an extra parameter to InsertHtml might be not what we expect as the best. First we should consider “full picture”, not only this case. There are potentially many behavior aspects we might want to parameterize regarding InsertHtml. And of cause you know what this could lead: combinatorial explosion of InsertHtml overloads. For instance, in that thread I gave you a link to we were requested to support style mapping and allow passing some map right to InsertHtml. Two features require four overloads, three – eight etc.
Adding a property to DocumentBuilder looks better from the first sight. But we should not forget import of complete documents to Aspose.Words document model. Import can be made right in the Document constructor:
Document doc = new Document(“DinnerInvitation.html”);
And there are already several constructors and Load methods in the library (for stream, for file, with or without format detection). If we add an extra parameter to them we’ll have the same combinatorial explosion.
In Aspose.Words we have SaveOptions but we have no LoadOptions. But there are also some irresolvable degrees of freedom when documents are being loaded. These two requests are good examples what could be done with LoadOptions or however we call it.
You are right, that’s not fast to make such changes in the library. At least we can suggest a workaround. When you are inserting an HTML fragment with an image reference you can switch to using DocumentBuilder.InsertImage. To detect this situation you probably need some regular expression parsing on the fragment. In general that fragment might contain anything else and you shouldn’t forget to process its remainders. Another idea is inserting the whole fragment and after that tuning ImageData of appropriate newly created Shape. Third idea is doing the same but after all insertions and before further processing. You can query all shapes in the document and suggest on each of them whether to load data from references or leave them as they are.
See these articles in our documentation:
Regarding further document saving that’s everything straightforward. I wrote you that a Document instance doesn’t “know” in what format it will be saved. Document class is the document model. When we save in a format without embedded images we put images separately on the file system. You can see that when exporting to HTML or Aspose.Pdf XML (intermediate format for PDF export).
I have created a new issue for your request in our defect database:
#5286 – Embed referenced resources optionally in HTML import
We’ll investigate this further but I cannot promise you any release date. At least this case will be addressed and some update provided.