speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
296 stars 36 forks source link

Space gets dropped before number #392

Closed pr-apes closed 2 years ago

pr-apes commented 2 years ago

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.

pgundlach commented 2 years ago

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

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

Thank you!

pr-apes commented 2 years ago

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 commented 2 years ago

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.

pgundlach commented 2 years ago

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.

pr-apes commented 2 years ago

Many thanks for the fix.

pgundlach commented 2 years ago

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

pgundlach commented 2 years ago
<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>