Are there place holders for the DocumentBuilder?

Hi.
I’m currently writting a wrapper class for Aspose, which we will use for a report builder, of which the output requirements is not yet defined. My idea was to have the wrapper construct the report in a linear way, in other words, as the content comes in, it is written onto the text document.
However, I’ve just received a curveball. It appears that one of the requirements is that if no content can fit under a heading, the heading must move to the next page (Or the next column on the same page) Now, I have a bit of a conceptual idea of how this could work, but I’m not quite sure if it will work and what aspose methods to search for.
Basically my plan is something like this. The Report builder will add reporting features as follows:

  1. Call a StartNoPageBreak method. This method will record the current page number and column number in a variable, as well as adding a place holder so the document builder can return to this point.
  2. Call AddHeading one or more headings.
  3. Call a EndNoPageBreak method. This method will again record the current page number and column number in a variable, and compare it with the same values from StartNoPageBreak. If these values differ, the documentbuilder must return to the earlier place holder, and add line breaks until the current page number equals the recorded page number of EndNoPageBreak.

However, I’m unsure whether ASPOSE will support:

  1. The said place holder to which the documentbuilder can return to.
  2. Getting the page and column number from the documentBuilder’s current position.

If ASPOSE does support this functionality, can you please direct me to the documentation that demonstrate how this should be done?
Else, if you can maybe improve on my idea, or suggest a better solution all together, it will be greatly appreciated.
Thanks

Hi Hanno,
Thanks for your inquiry.
I can suggest a simplier way to achieve what you are looking for. You can use the “Keep with next” paragraph option which will keep the first paragraph on the same page/column as the paragraph which follows this. If you set your heading paragraph with this option it will ensure the heading stays with the content even if they split across pages.
Please see the code below which demonstrates how to use this.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set to Heading 1 style and enable keep with next to keep the heading with the next paragraph.
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.ParagraphFormat.KeepWithNext = true;
builder.Writeln("Heading 1");
// Disable keep with next and set style formatting back to normal
builder.ParagraphFormat.KeepWithNext = false;
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Text Content");

Depending upon your specifications you may also want to look into “Keep together” which can also be found under ParagraphFormat. This will ensure that all lines in a paragraph stay on the same page together.
Thanks,

Has anyone ever told you guys you’re AWESOME?
Thanks so much for putting me on the right track.