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

Free Support Forum - aspose.com

Controlling line spacing between content in aspose word document

How can i controll line spacing between contents on Aspose word document.See the sample code as well as sample document below.
In the sample attachment we want to coontrol line spacing between content show in highlighted yellow.
See the sample code we are using and see the red section.This string builder is using doeumentbuilder object.

private string GetPracticeHtml(List FolderContentList)
    StringBuilder strPartice = new StringBuilder();
    int i = 0;
    if (FolderContentList != null && FolderContentList.Count > 0)
        strPartice.Append("<h6 style=‘margin:0px 0px 0px 0px;padding:0px 0px 0px 0px’><span style=‘font-size:11px;font-family:arial’>Practice Area</span></h6>");

        foreach (FolderContent foldContent in FolderContentList)
            EktronHelper.SortList<Wilmerhale.Common.Content>(foldContent.ContentList, "ContentTitle", SortDirection.Ascending);
            foreach (Wilmerhale.Common.Content content in foldContent.ContentList)
                i += 1;
                // strPartice.Append("<a class=‘dl-hide’ id=‘hs-" + i + "’ href=’" + content.Link + "’>" + content.ContentTitle + "</a>");

                strPartice.Append("<h6 style=‘margin:0px 0px 0px 0px;padding:0px 0px 0px 0px’><span STYLE=‘font-family:Arial;font-style:bold;font-size:11px;’>");
                strPartice.Append(content.ContentTitle); //— Need to control line spacing here.
                // strPartice.Append("<br/>");
                // strPartice.Append("<ul style=‘list-style:none; margin:0 0 10px 0’>");
                // strPartice.Append("<div style='font-size:10px;font-family:Arial;margin:0 0 0 0>");

                FolderContent folderContent = foldContent.FolderList.Find(delegate (FolderContent fContent) { return fContent.FolderID == content.ChildFolderID; });
                if (folderContent != null)
                    strPartice.Append(GetContentHtml(folderContent, ref strPartice, 1));
                // strPartice.Append("</div>");
                // strPartice.Append("</ul>");
    return strPartice.ToString();


Thanks for your inquiry. I believe, PageSetup class is what you’re looking for. PageSetup object contains all the page setup attributes of a section (left margin, bottom margin, paper size, and so on) as properties.

Best Regards,

We are running into issue while setting documentBuilder.ParagraphFormat.SpaceBefore and documentBuilder.ParagraphFormat.SpaceAfter in aspose document.Whatever we are setting here is being overwritten in the document…In the mainbiodetails mentioned below content is cuming out with lots of p tags we need to set space before and after that we require support on this urgently…See the attached file for reference…

documentBuilder.ParagraphFormat.SpaceAfterAuto = false;
documentBuilder.ParagraphFormat.SpaceBeforeAuto = false;
documentBuilder.ParagraphFormat.SpaceBefore = 12;
documentBuilder.ParagraphFormat.SpaceAfter = 0;


Thanks for your inquiry. Please note that, when you insert content by using InsertHTML method, whole formatting is taken from HTML snippet. In this case, Aspose.Words does not inherit formatting specified in DocumentBuilder options. I think, the workaround suggested in this post might be helpful to you in this situation.

Please let me know if I can be of any further assistance.

Best Regards,