How to count pages in a Write Pro document?

Dear,

How do you get the number of pages there is in a Write Pro
document by code. I’ve been looking for a property “wk page count”
or something similar, but can’t find anything useful.
With 4D write you could do: WR Count ($area;wr nb pages)

Best Regards
Magnus Torell

you can try something like that:

// Footer
$footer:=WP New footer($section)
// #TODO: ST Insert Expression -> wp insert formula v18R2
// WP INSERT FORMULA($footer;formula(this.pageNumber);wk append)
ST INSERT EXPRESSION($footer;"$wp_pageNumber";ST End text)
WP SET TEXT($footer;" / ";wk append;wk include in range)
// WP INSERT FORMULA($footer;formula(this.pageCound);wk append)
ST INSERT EXPRESSION($footer;"$wp_pageCount";ST End text)

Patrick

https://doc.4d.com/4Dv18/4D/18/WP-Get-page-count.301-4523030.en.html

1 Like

Hello Armin,

Thanks… Soo blind :slight_smile:

Regards
Magnus

Hello,
Starting with v18R2 you can also use WP Insert formula rather that ST Set expression.

This command is described here
https://doc.4d.com/4Dv18R2/4D/18-R2/WP-INSERT-FORMULA.301-4831015.en.html

In this case (v18r2), the formula could be << This.pageNumber >> (as a formula, not a string!

Managing formulas
https://doc.4d.com/4Dv18R2/4D/18-R2/Managing-formulas.300-4735040.en.html

regards

Roland Lannuzel

If you looked my code, you get ST INSERT EXPRESSION format and the new WP INSERT FORMULA (as comment) just below each instructions :wink: