Use $myWPCopy:=OB Copy(myWParea) first to enhanced it from a maybe existing UI,
and loop chars in copy not in original.
This can maybe (belongs to usecase) drastically speed up.
Do not forget, auto-page-breaks (not the hardcoded one) belongs to page-settings.
I build a solution what did exacly this and it is fast like real time with large document-text-contents.
I did this work before years when beta-writePro comes out,
i am not know 4D today expand in last years new WPpro commands/features to do this better.
(this i clearify by study new docu again anytime in future when i need it and had time)
So i did not know if today this own workarround is neeeded.
Sorry, i want only to point out that this can be done fast+working.
With fast as like real time, i mean One-Big-Document,
not scanning thousands of documents.
My solution only steps chars as it can see in 4D-KB example
plus enhanced it with obCopy
plus not stepping always all chars
(i did mixed steps with a lot of likely predicted calculations)
(logic is a little bit like try some predicted calculations and only when less than 250chars step all chars)
To adopt my solution (if no other way found)
there needs a long explaining of how to use it.
The source code is not my property, I was only the author on behalf of my employer.
This are two arguments why it is not easy possible for me to public the source code.
My suggestion, try to program your own method with myTipps
or search arround in 4D-docu what is today possible with WP
and for what is not a buildInSolution available.