Tech Tip: Finding and removing page breaks in 4D Write Pro document
PRODUCT: 4D | VERSION: 17 R | PLATFORM: Mac & Win
Published On: November 7, 2019
4D Write Pro offers a feature to insert page breaks programatically using WP INSERT BREAK but lacks the alternative for removing page breaks. Here is a utility method that will find the range position of the break and replace them with a new line instead.
// Method: removeAllPageBreaks // Description: // Parses through Write Pro area and removes all page breaks // // Parameters // $1 - Write Pro area // ---------------------------------------------------- C_OBJECT($1) C_OBJECT($range_o;$range2_o;$select_o;$pos_o;$pos2_o) C_LONGINT($i) C_TEXT($char_t) $range_o:=WP Text range($1;wk start text;wk end text) For ($i;$range_o.start;$range_o.end) $select_o:=WP Text range($1;$i;$i+1) $char_t:=WP Get text($select_o) // Get range of next char $range2_o:=WP Text range($1;$i+1;$i+2) // If char is new line or page break If ($char_t="") $pos_o:=WP Get position($select_o) $pos2_o:=WP Get position($range2_o) // If next char is on next page, save page break pos and replace with new line If ($pos_o.page#$pos2_o.page) WP SET TEXT($select_o;"\n";wk replace) End if End if // If char is \r, save page break pos and replace with new line If ($char_t="\r") WP SET TEXT($select_o;"\n";wk replace) End if End for |