There is NO magic formula to do this as it will be dependent on how the page was formatted originally.
In the best case scenario from your standpoint, you are dealing with straight text and the application has issued a formfeed for the page break. Then you only need to look for the FF, char(12), in the output. It can get complicated very quickly if raster images or fonts are embedded in the data stream that contain char(12)'s. You will have to do some detective work to look for a "foolproof" means of detecting the page break.
If the output is a basic "print and space" application where the page is defined by the margins defined in the page format code. Typically you might find there are 60 print lines on a letter size sheet. Partial pages are padded with blank lines to fill the page. In this case, you only need to keep a line count to determine the page break.
Jim Asman
jlasman@telus.net