Section(X).Range.Delete() - page breaks?


#1

To get around the issue of Aspose.Word being unable to merge formatted text, I have added several sections to a template, where I intend to delete each section as appropriate.

This works OK, except that if the section that is deleted is at the end of the document, it Aspose.Word leaves a blank page at the end. This occurs with both a continuous or new page section break. Is it possible to have it so blank pages are removed with the sections?

Regards,

Jat


#2

The blank page will certainly be fixed. Is it in one of the documents you already sent me or you have another one. Please email if its a different document because tests on my documents don’t leave empty page at the end.

I’m also still working on the latest document with drawings you sent me.


#3

Hi Jat,

First, your document is a bit strange in that it has only one visible section break but Word actually shows that there are 3 (three) sections. You can see this in Word status bar. It shows current section where the text cursor is. With one section break there can possibly be only two sections so there must be some other section break which is not visible (possibly Word glitch).

I played around and deleted the paragraph mark and the section break and inserted them again in your document and managed to get it right. So you should do the same. But that did not fix the empty page at the end.

The reason why empty page remains is that at the moment Aspose.Word does not delete whole last section together with the section mark. It only deletes content of the last section. I’ve implemented it this way to mimic Word behaviour when deleting section range.

So when you delete the last section you can actually see that the section mark (belonging to the first section) still remains and one paragraph mark in the second section remains.

All you can do now is to try to make sure that last paragraph mark fits on the previous page. It can be done by reducing bottom margin a little bit or reducing some space taken by text on the last page.

I will email you the document to illustrate what I mean.

This should be enough for you to eliminate the last empty page, but in the future
I will rethink the way Aspose.Word deletes the last section.


#4

I’m not going to send you the document.

Just reduce height of one of the big table cells by one text line or so and this will help to avoid the last blank page when deleting the last section.