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

Free Support Forum - aspose.com

Line spacing with InsertHTML

Hi,

I am currently evaluating this software and am trying to use DocumentBuilder to insert HTML into a Word document. If I insert an HTML paragraph it works, but it inserts it with line spacing set to 1.5 instead of single. How can I change this? I've tried setting ParagraphFormat.LineSpacing = 12 but it doesn't work.

My code looks like this:

Dim builder as New DocumentBuilder(doc)

Builder.MoveToMergeField("Test")

builder.ParagraphFormat.LineSpacing = 12

Builder.InsertHTML("

Some test data

")

My entire document should always have single line spacing, so if there is a way to update the line spacing for the whole document once I've finished inserting the HTML then this would do the trick.

Thanks,

Emma

Hi Emma,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can try using the following code to achieve this:

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToMergeField("Test");

builder.InsertHtml("

Some test data

");

Node[] nodeColl = doc.GetChildNodes(NodeType.Paragraph, true).ToArray();

// Loop through all Paragraphs.

foreach (Paragraph par in nodeColl)

par.ParagraphFormat.LineSpacing = 12;

// Save output document.

doc.Save("out.doc");

Best regards,

Thank you for the quick response, that worked perfectly.

Emma