Write Pro footer frame size?

Hi,

Is there a way to get a Write Pro footer frame width and height by code?
I want to set different images on each page of a Write Pro document and it must fit in the footer area of that particular page.

Attributes wk width and wk height always return 0 whatever range/element reference I try.

I already found the width by subtracting the left and right margin from the page width. But I can’t get the correct height of the frame.

v17R3

Kind regards,
Koen

Hello Koen

if you’re using v17 R3, you may have to wait for R4

There is a https://blog.4d.com/get-coordinates-in-a-4d-write-pro-document/BLOG> about this

The code below allows you to get the heigh of the content of the footer (or the header)
The function WP Get position has been improved and now returns an object “bounds” with top/left/right/bottom properties…

Pay attention : it’s the bounds of the content…so if your footer is empty, the height will be the height of a single line even if the footer can hold 10 lines
In the other hand, if the footer is full, or if you have written many thing inside the footer so as it has been automatically adjusted (to avoid overlap with the body) the result will be good.

Hope this helps !

<code 4D>
$foo:=WP Get footer(WParea;1)
$pos:=WP Get position($foo)
$height:=$pos.bounds.bottom-$pos.bounds.top

ALERT(String($height))

</code 4D>

Roland Lannuzel

Bonjour Roland,

Thanks for you suggestion, I guess it could work in my project. But I’ve another work around right now. And I’ll wait for future release to have the definitive solution.

Kind regards,
Koen

Hello

Second though: The height of the footer depends of its content. If the number of line increases, the height is adjusted so as there is no overlap on the body

(this also worth for the headers)

So, two heights have to be calculated. The first one is the regular height, the second is based on the content. The bigger one wins…

<code 4D>
C_REAL($height;$height1;$height2)
C_REAL($docMarginBottom)
C_REAL($fooMarginTop;$fooMarginBottom)

// if no section margin have been set, the document values will be returned
WP GET ATTRIBUTES(WP Get section([TEST]WP;1);wk page margin bottom;$docMarginBottom)

$foo:=WP Get footer([TEST]WP;1)
If (Not($foo=Null))

  // When the content of the footer fits in the height, the value $height1 is OK
WP GET ATTRIBUTES($foo;wk margin top;$fooMarginTop)
WP GET ATTRIBUTES($foo;wk margin bottom;$fooMarginBottom)
$height1:=$docMarginBottom-($fooMarginTop+$fooMarginBottom)

  // When the footer contains a lot of lines, it's size might have been increased
$foo:=WP Get footer([TEST]WP;1)
$pos:=WP Get position($foo)
$height2:=$pos.bounds.bottom-$pos.bounds.top

If ($height1>$height2)
	$height:=$height1
Else 
	$height:=$height2
End if 

Else
$height:=0
End if

ALERT(String($height))
</code 4D>

Hope this helps
Roland