I am trying to generate word documents on the server side by using a template (with a bunch of content controls) and html data from a back-end data store. It looks like Aspose doesnt support content controls completely (retrieving content controls by tag etc.,). This can be easily achieved by using openXml SDK but I dont have a nice tool to convert html into openXml. It looks like Aspose does a very good job there…now, can i use the combination of aspose library and openxml?
something like this -
string tag = “MyContentControl”;
SdtBlock cc = mainPart.Document.Body.Descendants().Where
(r => r.SdtProperties.GetFirstChild().Val == tag).Single();
Aspose.Words.Markup.StructuredDocumentTag asposeDocumentTag = GetAsposeSDTFromOpenXmlSDT(cc);
or is there any other way of retrieving Aspose StructuredDocumentTag objects using content control tags?
Thanks for your request. unfortunately, there is no direct way to achieve this. However, if your main purpose is inserting HTML content into SDT controls, I think, you can achieve this by doing the following:
1. Load HTML into Aspose.Words.Document;
2. Save the document as DOCX;
3. Open DOCX document using OpenXml SDK;
4. Extract content from the document using OpenXml SDK;
5. Insert the extracted content into SDT using OpenXml SDK.
Hope this helps.
Thanks for your response Alexey. That is exactly what I ended up doing. Instead of saving the file on the file system, i saved the file in an in-memory stream and opened it using openxml.
Any ETA on when this feature will be included in Aspose?
Thanks for your request. We plan to provide access to properties of SDT objects in one of future versions. Most probably this feature will be available in August. But I cannot promise you anything at this stage.