publisher icon indicating copy to clipboard operation
publisher copied to clipboard

Space gets dropped before number

Open pr-apes opened this issue 2 years ago • 7 comments

Hi @pgundlach, this issue comes from #388:

<Layout xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en">

  <SetGrid width="1mm" height="1mm"/>

  <Record element="data">
    <SetVariable variable="myfile" select="$external_pdfdoc"/>
	<Output>
	<Text>
	<Paragraph>
    <Value select="sd:number-of-pages($myfile)"/>
	<Value> </Value>
    <Value select="sd:imagewidth($myfile)"/>
	<Value> </Value>
    <Value select="sd:imageheight($myfile)"/>
	<Value> </Value>
    <Value select="sd:aspectratio($myfile)"/>
	</Paragraph>
      </Text>
    </Output>
  </Record>

</Layout>

The output from sp -v external_pdfdoc=../a.pdf --autoopen --dummy reads:

1 297 2101.41428570553

With any PDF document, I get no space before the output from <Value select="sd:aspectratio($myfile)"/>.

I only get an space before, if I replace it with &nnbsp; (I get no space even with &nbsp;).

Is this a bug or am I missing something basic?

Many thanks for your help.

pr-apes avatar Jul 07 '22 09:07 pr-apes

This is a bug. A workaround would be to add string() here:

<Value select="string(sd:aspectratio($myfile))"/>

Thank you!

pgundlach avatar Jul 07 '22 09:07 pgundlach

BTW, in https://github.com/speedata/publisher/discussions/388#discussioncomment-3098943 you mention imagewidth().

I cannot find this expression (imagewidth()) in the docs or in this repository (searching inside GitHub).

I guess it is related to current PDF (the document generated by Publisher), but how would be imagewidth() invoked?

Many thanks for your help.

pr-apes avatar Jul 07 '22 10:07 pr-apes

Sorry, I think that with this:

sd:imageheight($myfile, 'mm') returns the number of millimetres (same with imagewidth()).

you simply meant sd:imagewidth($myfile, 'mm').

Sorry for the noise again.

pr-apes avatar Jul 07 '22 10:07 pr-apes

Sorry, I think that with this:

sd:imageheight($myfile, 'mm') returns the number of millimetres (same with imagewidth()).

you simply meant sd:imagewidth($myfile, 'mm').

exactly, sorry for not being clear.

pgundlach avatar Jul 07 '22 10:07 pgundlach

Many thanks for the fix.

pr-apes avatar Jul 08 '22 06:07 pr-apes

This has some unwanted side effects... I need to re-open the issue.

pgundlach avatar Jul 21 '22 15:07 pgundlach

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">

    <Record element="data">
        <PlaceObject>
            <Textblock>
                <Paragraph>
                    <Span background-color="lightgray">
                        <Value>abcdef</Value>
                        <Value> </Value>
                    </Span>
                </Paragraph>
            </Textblock>
        </PlaceObject>
    </Record>
</Layout>

pgundlach avatar Jul 22 '22 07:07 pgundlach