wrong conditional handling?
pr-apes opened this issue · comments
I have the following layout for a source file:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Record element="data">
<Loop select="12" variable="runpage">
<Pageformat
width="{if (sd:odd(sd:current-page())) then '297mm' else '210mm'}"
height="{if (sd:even(sd:current-page())) then '297mm' else '210mm'}"
/>
<PlaceObject>
<Textblock>
<Paragraph>
<Value select="sd:dummytext(10)"/>
</Paragraph>
</Textblock>
</PlaceObject>
<ClearPage/>
</Loop>
</Record>
</Layout>
The output is processed with the following layout:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Record element="data">
<PlaceObject>
<Textblock>
<Loop select="sd:number-of-pages($pdfdoc)" variable="runpage">
<Paragraph>
<Value select="sd:aspectratio(concat($pdfdoc, ':', $runpage, ':mediabox'))"/>
</Paragraph>
</Loop>
</Textblock>
</PlaceObject>
<ClearPage/>
<Loop select="sd:number-of-pages($pdfdoc)" variable="runpage">
<PlaceObject column="105mm" row="148.5mm" hreference="center" vreference="middle">
<Image file="{$pdfdoc}" page="{$runpage}"
rotate="{if (not(sd:aspectratio(concat($pdfdoc, ':', $runpage ':mediabox')) > 1)) then '0' else if (sd:odd($runpage)) then '-90' else '90'}"/>
</Paragraph>
<ClearPage/>
</PlaceObject>
</Loop>
</Record>
</Layout>
I'm afraid that the main conditional for the rotation doesn't work when the page is portrait. It handles all pages as landscape.
I'm afraid this might be a bug in Publisher (and I would say this worked fine before). Could you check this?
Many thanks for your help.
Your second layout is invalid XML.
I get the following output (1st page)
1.4142851389653 0.70707099470169 1.4142851389653 0.70707099470169 1.4142851389653 0.70707099470169 1.4142851389653 0.70707099470169 1.4142851389653 0.70707099470169 1.4142851389653 0.70707099470169
Which looks correct?
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<SetVariable variable="pdfdoc" select="'out.pdf'"></SetVariable>
<Record element="data">
<PlaceObject>
<Textblock>
<Loop select="sd:number-of-pages($pdfdoc)" variable="runpage">
<Paragraph>
<Value select="sd:aspectratio(concat($pdfdoc, ':', $runpage, ':mediabox'))" />
</Paragraph>
</Loop>
</Textblock>
</PlaceObject>
<ClearPage />
<Loop select="sd:number-of-pages($pdfdoc)" variable="runpage">
<PlaceObject column="105mm" row="148.5mm" hreference="center" vreference="middle">
<Image file="{$pdfdoc}" page="{$runpage}"
rotate="{if (not(sd:aspectratio(concat($pdfdoc, ':', $runpage ':mediabox')) > 1)) then '0' else if (sd:odd($runpage)) then '-90' else '90'}" />
</PlaceObject>
<ClearPage />
</Loop>
</Record>
</Layout>
Many thanks for spotting the error, @pgundlach.
The issue was trickier: I wrote sd:aspectratio(concat($pdfdoc, ':', $runpage ':mediabox'))
, which should read sd:aspectratio(concat($pdfdoc, ':', $runpage, ':mediabox'))
.
It was missing a comma in concat()
. This fixes the sample. I have to look further, since the actual document is still not working fine.