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

Free Support Forum - aspose.com

Delete Blank Lines under Word Table using C# .NET | Set Line Spacing Rule for Paragraphs to Exactly

Hello experts,

When I insert a table in the word, there will be a blank line below the table, i know this is the word default behavior or rule, but in my project, when the question 3 is full fill the page 1 and set the question 4 “Allow row to break across the page” property is false, there will be a blank page after page 1, the blank is not what i expected.
image.jpg (211.5 KB)

how to check the the table happen to be the bottom of the page, e.g.image.png (27.3 KB)

and is there a way to remove the blank line of the specify table, e.g.image.png (27.3 KB)

I know a method to resolve this in the word,
image.png (28.6 KB)
But, how to check and resolve the issue using Aspose.Word API, the version 19.8

the attached document (blankPage.docx) bankPage.zip (644.4 KB)

Please advise, thk,


Please also ZIP and attach your expected DOCX file showing the desired output here for our reference. You can create this document by using MS Word. Please also list the complete steps that you performed in MS Word to create the expected document on your end. We will then investigate your scenario further and provide you code to achieve the same by using Aspose.Words for .NET API. Thanks for your cooperation.

Thanks for your reply,
I have attached my expected document (expected.docx)expected.zip (644.3 KB)
Unlike the original document, the blank lines on the second page were deleted.(original.docx)original.zip (644.3 KB)

The follow is complete steps
1、create a MS word, set compatibility mode of 2010
2、insert the question content to document, the question 3 and 4 is table with one row, then set the question 3 and question 4 table property “Allow row to break across the page” is false, because the question 3 table is right at the bottom of the page 1, and question 4 content is overlap the page content, there will be a blank page , please reference the original.docx document.
3、I expected is to find and delete the blank page
4、the bellow is my find in MS word how to operate
1)、Move to the cursor to the blank line
2)、Right-click select the paragraph
3)、Set the line space exactly 1 pt, image.png (383.5 KB)

4)、It will “delete” the blank page to achieve what i expected.image.jpg (279.6 KB)

It’s all the information what i can provide you, look forward to your reply.


We are checking this scenario and will get back to you soon.

I’m looking forward your reply. thk,


Thanks for being patient. Please check these simplified input/output Word documents and try running the following code:

C# Code:

Document doc = new Document("E:\\Temp\\input.docx");

Paragraph targetPara = doc.FirstSection.Body.FirstParagraph;
targetPara.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
targetPara.ParagraphFormat.LineSpacing = 1;


Hope, this helps in achieving what you are looking for.

Thanks for your reply,

we are looking for alternative method to resolve it, it’s difficult for us to check the line space position,this is the crux of the matter.


One way is to look for empty Paragraphs after Tables and then adjust their Line Spacing:

Document doc = new Document("E:\\Temp\\211869\\original.docx");

foreach (Table table in doc.FirstSection.Body.GetChildNodes(NodeType.Table, true))
    Paragraph targetPara = (Paragraph)table.NextSibling;
    if (targetPara != null && string.IsNullOrEmpty(targetPara.ToString(SaveFormat.Text).Trim()))
        targetPara.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
        targetPara.ParagraphFormat.LineSpacing = 1;