I’d like to control my pagebreaks by determining the available space on
the current page.
My documents have elements which should not stand alone on the
end of a page (e.g. headlines).
So I want to determine the available height on the current page and
compare it with the height of the current element plus the height of the following
element (which is allowed to stand on page end).
Is it possible to get this information?
Or is it possible to determine wether there is enough space on the current page.
Or are there other ways to reach this behaviour?
Thank you for your help in advance.
There is no pagination logic in Aspose.Word at the moment. It will only be there when Aspose.Word supports previewing and printing.
thank you for your quick response.
Does Aspose.Word plan to support such logic in future?
Printing, preview and pagination will be available in the future. I will think about exposing information about empty space on a page too.
By the way, if you want to control pagination only to make sure that paragraphs and headings are arranged in a proper way you should use paragraph properties:
KeepTogether - True if all lines in the paragraph are to remain on the same page. KeepWithNext - True if the paragraph is to remains on the same page as the paragraph that follows it.
PageBreakBefore - True if a page break is forced before the paragraph.
WidowControl - True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph.
These might also be useful:
SpaceAfter - Gets or sets the amount of spacing (in points) after the paragraph.
SpaceBefore - Gets or sets the amount of spacing (in points) before the paragraph.
These are all properties of the ParagraphFormat class available when you insert content using DocumentBuilder.
Let me know if that solves your problem.
Thank you for your quick response.
These properties sound great!
I’ll try them and let you know if this works
within my project.
I've tried the properties for paragraphs,
this works fine!
Thank you for your great help.
regarding newest requirements to my documents,
it is necessary to know the empty space on a page.
Is it possible get this information?
Thank you in advance,
No, it is not possible, at least until Aspose.Word gets its pagination engine.
The fact that you need to know the empty space on a page suggests you need to do some pretty low-level work with document content and this sounds stange. Never in text editors or report designers users have to deal explicitly with empty space on a page - that’s what the system is normally doing for you - managing the content and empty space in an automatic and efficient manner.
Maybe if you let me know what do you want to do in more details, I could suggest an alternative solution. I thought the paragraph properties that control pagination solved your problem.
Thank you for your quick respone.
I want to delete empty paragraphs, if they are the first ‘item’ on a new page.
Therefore I wanted to compare the available height of the odd page and the height of the empty paragraph.
The paragraph properties are pretty good for controlling for elements which should
be printed in a specific way (kept together and so on). But the elements are printed in every case.
I didn’t discover a way to use these properties for preventing a element to be printed. But perhaps there is another functionality in Aspose.Word which
could help me with this issue.
Whatever you are trying to do sounds a bit complicated to me. Maybe it can be simplified somehow.
What do you mean by “elements”, what are they? If these are some blocks of text inside the document, maybe you can separate it into sections and delete sections you don’t need based on some logic. At the moment there is no other way to hide or remove content from the document.
Thank you for your quick response.
Sorry I just used the expressions I'm using within my project and
maybe I've problems to express me correct due to my english is not
"Elements" are text, headlines, images, paragraphs and so on.
I'm building my worddocuments with the Documentbuilder.
So, theres only a 'empty' word document on the server (and
this a requirement).
The user of my programm (a reportengine) can add different "elements" to a report
(I encapsulate the aspose.word instructions),
and there should be the opportunity to add a empty line for pretty appearance of the document.
If the user adds such a empty line, the user doesn't want to add it at the beginning of a new page.
My job is that the user doesn't have to take wether there will be a
pagebreak or not. Furthermore the user can't know if there will be a pagebreak
when he adds tables with dynamic content.
So I want to "catch" this case by not printing the empty line to the document at the beginning of a page.
In my idea, I have to get the information when a new page is started
or will be started to prevent the whitespace-paragraph from printing at the
beginning of a new page. I can't see another way to do so.
It's a helpful tip to remove content by using sections, but to decide wether
I want to remove it, I need the information if this is the beginning of the page.
I hope my explanation is not too confusing.