Ability to insert raw vml into document using C#

does word Support Insert VML Graph to SpecifiedSpecified DomainDomain in word ?

if can can you send a Sample to me thanks!

Hi Juao,

Thanks for your query. I regret to share with you that the requested feature is not available at the moment in Aspose.Words. However, we had already logged this feature request in our issue tracking system. I have linked this thread to appropriate feature request and you will be notified via this forum thread once this feature is available.

The feature request ID in our issue tracking system is WORDSNET-4973.

We are really very sorry for your inconvenience.

Hi there,

Thanks for your inquiry.

Tahir is correct that there is currently no way to directly insert VML into your document. There is however a work around you can use for the time being. I will explain below.

The VML that you want to insert can be wrapped into a full WordML document and that document opened in Aspose.Words. The image can then be extracted and inserted just like when inserting a document. However note, that this may not work for some instances of VML so you will check if it works on your end.

Please see the code below for a demonstration of how to use the work around and the required code:

Document doc = new Document(); 

DocumentBuilder builder = new DocumentBuilder(doc);

string vml = "";

VmlImageHelper.InsertVml(builder, vml);


public class VmlImageHelper

{

public static void InsertVml(DocumentBuilder builder, string vml)

{

if (mBaseXml == null)

mBaseXml = GetWordMLOfEmptyDocument();

string preparedVml = string.Format("{0}", vml);

string combinedBaseAndVml = mBaseXml.Replace("", preparedVml);

MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(combinedBaseAndVml));

Document doc = new Document(stream);

foreach (Node node in doc.FirstSection.Body.FirstParagraph.ChildNodes)

builder.InsertNode(builder.Document.ImportNode(node, true));

}

private static string GetWordMLOfEmptyDocument()

{

Document doc = new Document();

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.WordML);

return Encoding.UTF8.GetString(stream.ToArray());

}

private static string mBaseXml;

}

If there are any issues, please let me know.

Thanks,

Hi, I read here that VML are not supported yet when importing html.

Is this work around still the best/only way to solve the issue?

Thank you.

Hi there,


Thanks for your inquiry. Aspose.Words does not import VML into DOM while loading html document. However, if you can extract the VML from the html, you can use the same workaround. Please note that this may not work for some instances of VML so you will check if it works on your end. Hope this helps you.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan