Closed pr-apes closed 1 year ago
This is a bug and I don't really know how to work around it. This is a more simple test case:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Pagetype name="foo" test="true()" width="297mm" height="210mm" />
<Record element="data">
<!-- <Message select="sd:current-row()"/> -->
<Message select="$_pagewidth"/>
<Message select="$_pageheight"/>
</Record>
</Layout>
Workaround:
If you uncomment the first Message, the page is initialised by the sd:current-row()
and then the page width and height are set correctly.
This should be documented though....
Perhaps I should stop using these page-dependent variables and expose them as functions?
There are now two xpath functions for page detection (sd:pagewidth()
and sd:pageheight()
) See https://doc.speedata.de/publisher/en/xpathfunctions/index.html#_sd_layout_functions
These functions are great to have.
Many thanks for your help.
I have just tested them and I'm afraid that these functions have problems to place content:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Record element="data">
<!--<PlaceObject column="{$_pagewidth * 0.5}" row="{$_pageheight div 2}" hreference="center" vreference="middle">-->
<!-- <Image file="{$pdfdoc}" width="{$_pagewidth div 2}" page="1"/>-->
<!--</PlaceObject>-->
<PlaceObject column="{sd:pagewidth('sp') * 0.5}" row="{sd:pageheight('sp') div 2}" hreference="center" vreference="middle">
<Image file="{$pdfdoc}" width="{sd:pagewidth('sp') div 2}" page="1"/>
</PlaceObject>
</Record>
</Layout>
With the code above (run invoking sp --dummy -v pdfdoc=misplaced.pdf
and with the sample from the original comment), there is no visible placement at all (Publisher reports conflict in grid).
You need to add the unit sp
, otherwise this is without dimension and will be interpreted as grid cells.
<PlaceObject column="{sd:pagewidth('sp') * 0.5}sp" row="{sd:pageheight('sp') div 2}sp" hreference="center" vreference="middle" frame="solid">
<Image file="{$pdfdoc}" width="{sd:pagewidth('sp') div 2}sp" page="1"/>
</PlaceObject>
@pgundlach,
I wonder whether it would be possible that sd:pagewidth()
could add the dimension in the result and behave similar to $_pagewidth
.
This would result in the same behavior from $_pagewidth
and sd:pagewidth()
. Since the function is brand-new, it won't break backwards-compatibility.
Many thanks for your help.
But it makes calculation easier if I leave out the unit and it is closer to the behaviour of the other width/height functions.
In that case, it is perfectly fine for me.
Many thanks for your help.
@pgundlach,
this almost obvious sample (run with
sp --dummy --jobname=misplaced
):With this source run with
sp --dummy -v pdfdoc=misplaced.pdf
:The page is misplaced with
<Pagetype>
:A workaround is the commented
<Pageformat>
:I don't know what am I or is missing here.
Many thanks for your help.