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

Free Support Forum - aspose.com

End of section discrepancy Aspose 18 vs 21

Dear Sir or Madam,

We are currently evaluating Aspose v21 to upgrade from v18. I noticed that in Aspose-21 there are end of section markers appeared in the end of each section which adds extra visible blank line to the document.(see the screenshot attached). Is there any way to avoid this blank lines?


Aspose18-21.PNG (266.4 KB)
Aspose-18.zip (130.3 KB)

@AlexanderNovickov Could you please provide a simple code you use to generate the attached document? We will check and provide you more information.
If you simply need to remove all section breaks and empty paragraphs in your document, you can use code like the following:

Document doc = new Document(@"C:\Temp\Aspose-21.docx");
//Replace section breaks with an empty string.
doc.Range.Replace("&b", "");
// Remove empty paragraphs.
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Paragraph para in paragraphs)
    if (!para.HasChildNodes)

Hi Alexey,

Sorry for late reply. I am trying to create a small project reproducing the issue but it’s a bit tricky. I can’t delete neither section breaks nor empty paragraphs in the document, they are needed. I just want to figure out while the section breaks appear in Aspose 21 and why they are visible. If there’s a way to make them 0-height that would be enough for me.

@AlexanderNovickov You can use the following code to change font size of the empty paragraph with a section break:

Document doc = new Document(@"C:\Temp\in.docx");

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Section sect in doc.Sections)
    if (!sect.Body.LastParagraph.HasChildNodes)
        sect.Body.LastParagraph.ParagraphBreakFont.Size = 0;


Thank you Alexey,

I think it’s a solution I was looking for. One more question if you don’t mind. Currently if I try to save a docx document produced with Aspose it tries to save it as a Strict Open XML document by default. Is there a way to make it a Word document?

Thank you,
SaveAs.PNG (3.2 KB)

@AlexanderNovickov Most likely in your code you have specified OoxmlCompliance.Iso29500_2008_Strict, in this case if you open the generated document in MS Word and select Save As, MS Word selects Strict Open XML document by default.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello, World");
OoxmlSaveOptions options = new OoxmlSaveOptions();
options.Compliance = OoxmlCompliance.Iso29500_2008_Strict;
doc.Save(@"C:\Temp\out.docx", options);

If you save the document to DOCX without specifying OoxmlCompliance, i.e. using default OoxmlCompliance.Ecma376_2006 MS Word will suggest Word Document as default save format.

Hi Alexey,

Thank you for suggestion. If I don’t save with OOXML compliance option, then Word opens the document in the compatibility mode. I tried to use Iso29500_2008_Transitional and looks like it did the trick for me. Is there any caveats in saving with Transitional option? What’s the difference between OoxmlCompliance enum values?

Thank you in advance,

@AlexanderNovickov OoxmlCompliance enum values represents different OOXML standards. There is no caveats in saving with Transitional option. Transitional compliance differs from Strict that it allows using alternate content to provide backward compatibility with older versions of MS Word.