11
Views
7
Comments
Solved
[MSWordUtils] How can I ensure that the heading and its related content always stay together, even
mswordutils
Web icon
Forge asset by Stuart Harris
Application Type
Traditional Web

I am using the MSWordUtils Forge component in OutSystems. I have a Word template saved in the Resources folder, and I’m dynamically populating this template with data fetched from the database at runtime. This is used to generate and download a resume.

However, I'm facing an issue where for some sections, the section heading appears at the bottom of one page, and the related content starts on the next page, which breaks the layout and doesn’t look professional.

Since the content length varies for each user and is generated dynamically, I don’t know in advance where to place a page break.

How can I ensure that the heading and its related content always stay together, even when the data is dynamic and the length is unknown?


Template.docx
Screenshot 2025-06-25 at 4.28.22 PM.png
2024-11-07 03-28-42
Stuart Harris
Champion
Solution

Hi Salini,

I think you could do this with MSWord table settings. 

I moved the CERTIFICATIONS and ACADEMIC HISTORY headings into the first row of the table.

Then just for that row, I did the following (see image):

  • adjusted the left ident so it is on the left of the page matching the other headings
  • Set the height to be 1cm so the spacing is the same between the heading and the rows (you may want to change this a bit
  • Unchecked "Allow row to break across pages"
  • Checked "Repeat as header row at the top of each page.

Then the heading should stick with the first row, and also if it gets a page long, it will reappear on the next page.

Here is a link to the updated template.

I hope this helps!

Kind regards,

Stuart


UserImage.jpg
Salini Gupta

Hi Stuart,


Thank you for your response. The solution worked well for the table section in the shared template.

However, I have another Word template using the same MSWord Utils forge component, where I’m facing a similar issue. In this case, I’m unsure how to ensure that the section heading stays with the table to prevent them from breaking across pages. I’ll attach the blank template for your reference — please let me know if there's a way to handle this cleanly for other sections as well other than table.

Also, I’d like to improve the readability of the Project section text, as it currently appears very clumsy and crowded. Is there a way to add line spacing (or paragraph spacing) using the forge component or template formatting? I tried to add in template for section line spacing 1.25 but it didnt got applied to the file when downloaded.


Thank you for your response. The solution worked well for the table section in the shared template.

However, I have another Word template using the same MSWord Utils forge component, where I’m facing a similar issue. In this case, I’m unsure how to ensure that the section heading stays with the table to prevent them from breaking across pages. I’ll attach the blank template for your reference — please let me know if there's a way to handle this cleanly.

Also, I’d like to improve the readability of the Project section text, as it currently appears very clumsy and crowded. Is there a way to add line spacing (or paragraph spacing) using the forge component or template formatting?

Templateold.docx
2024-11-07 03-28-42
Stuart Harris
Champion

Great, I'm glad that worked for you. It would be great if you could mark the answer as the solution, so other community members can benefit.

For your next issue, headings outside of a table, MSWord does not have any method for keeping text together as far as I'm aware.

For the project text, do you mean that you have set paragraph spacing but the generated document does not use it?

Unfortunately the underlying library is quite limited. So any additional functionality would require using a different commercial library like Aspose.Words or similar.

Kind regards,

Stuart

UserImage.jpg
Salini Gupta

Hi Stuart,

No worries — I was able to figure it out within the Word file itself by using line spacing and enabling the “Keep with next” option to prevent unwanted page breaks.

So far, it’s working as expected. I’ll keep an eye out in case anything unusual shows up in other dynamic resumes during downloads.

Thanks!


2024-11-07 03-28-42
Stuart Harris
Champion
UserImage.jpg
Creckk Accessories

You can apply KeepWithNext to the heading and KeepLinesTogether to the following paragraphs. This keeps them on the same page when generating with MSWordUtils. Works best if you wrap both in a block or bookmark this car page. https://creckk.com/

creckk logo tredmark-01 (2).png
UserImage.jpg
Salini Gupta

Thank You.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.