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?
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):
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
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.
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?
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.
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!
Great, awesome work Salini!
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/
Thank You.