These are chat archives for speedata/publisher

14th
Feb 2018
Marius Räsener
@elmcrest
Feb 14 10:19
:scream: Hurenkinder!!! :D
Marius Räsener
@elmcrest
Feb 14 11:42
@pgundlach in watch mode, sp deletes the data.xml in the hotfolder. is that expected?
Patrick Gundlach
@pgundlach
Feb 14 11:45
@elmcrest yes, that is done on purpose. I should document it.
Marius Räsener
@elmcrest
Feb 14 11:47
probably we should stick to english since non-german speakers are also here
so, I don’t understand than how the watch mode is ment to be used
or maybe that’s an issue related to my editor. if the file gets delete on the filesystem, the editor closes the file
but probably I can configure this behaviour
Patrick Gundlach
@pgundlach
Feb 14 11:49
this is probably another use case. Say you have a setup with layout/images/fonts in directory A on your harddrive and have a software that exports data files to directory B
Now the watchdog sees a new data file in directory B (the watched dir) and uses this new data file to generate a PDF and puts it somewehre. The job is now finished and we don't need the data file in directory B anymore so it gets removed
Marius Räsener
@elmcrest
Feb 14 11:51
but then the changes made in layout.xml aren’t recognized, right?
Patrick Gundlach
@pgundlach
Feb 14 11:51
It is currently not configurable, the file always gets delted
right, in this case (above) the changes in directory A are not watched
Marius Räsener
@elmcrest
Feb 14 11:51
ok, I guess I can configure the editor to just run sp when I save a file
Patrick Gundlach
@pgundlach
Feb 14 11:52
I usually have a keyboard shortcut in my editors that run sp when I press F12
Marius Räsener
@elmcrest
Feb 14 11:52
alright
thx for your help
Marius Räsener
@elmcrest
Feb 14 12:43
@pgundlach are there examples for how the data should be structured? I’m rather unexperienced yet with XML itself, so this would help me...
so something more meaningful than the snippets in the manual
Patrick Gundlach
@pgundlach
Feb 14 12:44
I always try to arrange the data from top to bottom, from left to right, but it depends on the exact use case
Marius Räsener
@elmcrest
Feb 14 12:46
<data>
    <recipient>
    Fa. Wunderbar im Geschäft GmbH
    z.H. Max Mustermann
    Musterstraße 23a
    12345 Musterhausen
    </recipient>
    <header>
    Sehr geehrte Damen und Herren,

    viele Dank für alles, hier ist das Angebot:
    </header>
</data>
ah, ok
so I’d rather place the actual values into attributes, right?
Patrick Gundlach
@pgundlach
Feb 14 12:46
You could think of inserting <br /> into the data, but that is not strictly necessary
No, that is ok.
I tend to do it, as you have slightly more control over whitespace, but it should work either way
Marius Räsener
@elmcrest
Feb 14 12:47
ok, when I have two „PlaceObject“ in layout.xml I end up with two times the same content in the PDF
yeah sure, once I create the data dynamically from the DB <br /> makes more sense
oh, I just noticed, I have two times the content anyway
right now, a have a second page
hmm
  xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en">

  <Options mainlanguage="German" />
  <Trace hyphenation="yes" />

  <Record element="data">
    <PlaceObject row="1" column="1">
      <Textblock element="recipient">
        <Paragraph>
          <Value select="."/>
        </Paragraph>
      </Textblock>
      <Textblock  element="header">
        <Paragraph>
          <Value select="."/>
        </Paragraph>
      </Textblock>
    </PlaceObject>
  </Record>
</Layout>
I guess I have to read again some parts of the manual :P
Patrick Gundlach
@pgundlach
Feb 14 12:49
with PlaceObject you can specify which child element..
<PlaceObject>
  <Textblock>
    <Paragraph>
      <Value select="recipient"></Value>
    </Paragraph>
  </Textblock>
</PlaceObject>
Marius Räsener
@elmcrest
Feb 14 12:50
ah
Patrick Gundlach
@pgundlach
Feb 14 12:50
when you specify row="1" column="1" the always tries to avoid placing things ontop of each oterh
Marius Räsener
@elmcrest
Feb 14 12:51
ok with select and the element name it works now
Patrick Gundlach
@pgundlach
Feb 14 12:51
And create a PlaceObject for each <Textblock>
Marius Räsener
@elmcrest
Feb 14 12:51
:thumbsup:
Patrick Gundlach
@pgundlach
Feb 14 12:51
It might work with two <Textblock> within one <PlaceObject>, but this might change in the future
Marius Räsener
@elmcrest
Feb 14 12:52
it was pushing the second <Textblock> on the next page
ok, cool
time to take my dog for a walk :P :dog:
Patrick Gundlach
@pgundlach
Feb 14 12:52
it was pushing the second <Textblock> on the next page
interesting
Marius Räsener
@elmcrest
Feb 14 12:55
second placeobject.jpeg
single placeobject.jpeg
Patrick Gundlach
@pgundlach
Feb 14 12:57
good, that keeps users from placing more than one object in PlaceObject ;-)
Marius Räsener
@elmcrest
Feb 14 14:10
hehe yeah :P
Marius Räsener
@elmcrest
Feb 14 14:41
@pgundlach I’d now like to place the letterhead (page 1 is different than the rest) on the PDF
I was thinking pagetype is the correct element, but it doesn’t work
using Image works but then Overlay didn’t … so in case you’re here and throw in a hint I’d be thankful :P
Marius Räsener
@elmcrest
Feb 14 14:59
$ sp --wd='/Users/elmcrest/projects/speedata-publisher/hotfolder/'
Working directory now: /Users/elmcrest/projects/speedata-publisher/hotfolder/
Run speedata publisher
Loading file sdini.lua ... done
Load file: "publisher.lua" ...
Load file: "commands.lua" ...
Load file: "tabular.lua" ...
Load file: "tabular.lua" ... done
Load file: "paragraph.lua" ...
Load file: "paragraph.lua" ... done
Load file: "commands.lua" ... done
Load file: "grid.lua" ...
Load file: "grid.lua" ... done
Load file: "layout_functions.lua" ...
Load file: "layout_functions.lua" ... done
Load file: "publisher.lua" ... done
Start processing
Talking to server on port 55649
LuaTeX version 79.1
Loading hyphenation patterns "hyph-en-gb.pat.txt".
Language id: 0
Loading layout instructions "/Users/elmcrest/projects/speedata-publisher/hotfolder/layout.xml"
Error: ...rs/elmcrest/projects/speedata-publisher/sw/lua/luxor.lua:69: bad argument #1 to 'gsub' (string expected, got nil)
stack traceback:
    .../projects/speedata-publisher/sw/lua/publisher/spinit.lua:48: in function 'call'
    .../projects/speedata-publisher/sw/lua/publisher/spinit.lua:305: in function 'main_loop'
    .../projects/speedata-publisher/sw/lua/publisher/spinit.lua:337: in main chunk
    [C]: in function 'require'
    [\directlua]:1: in main chunk
Stop processing data
1 errors occurred
Duration: 0.184270 seconds

No pages of output.
Transcript written on publisher.log.
Total run time: 244.160279ms
Patrick Gundlach
@pgundlach
Feb 14 15:23
@elmcrest <Pagetype> is the way to go. You can place the header in <AtPageCreation>
the error above looks like an XML error.
Marius Räsener
@elmcrest
Feb 14 15:24
yeah, I’ve found meanwhile examples at github
<Layout
  xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en">

  <Pageformat width="210mm" height="297mm" />
  <Options mainlanguage="German" />
  <SetGrid height="5mm" width="5mm" />
    <Trace
    assignments="yes"
    objects="yes"
    verbose="yes"
    grid="yes"
    gridallocation="yes"
    hyphenation="yes"
    textformat="yes"
    />

  <Pagetype name="first_page" test="sd:current-page() = 1">
    <Margin left="0" right="0" top="0" bottom="0"/>
    <PositioningArea name="alles">
        <PositioningFrame width="210mm" height="297mm" row="0" column="0"/>
    </PositioningArea>
    <AtPageCreation>
        <PlaceObject row="0" column="0" area="alles">
            <Image file="soft_briefbogen.pdf" row="0" column="0">
        </PlaceObject>
    </AtPageCreation>
  </Pagetype>

  <Record element="data">
  <NewPage pagetype="first_page" />
      <PlaceObject area="alles">
    <Textblock>
        <Paragraph>
        <Value select="recipient"/>
        </Paragraph>
    </Textblock>
    </PlaceObject>  
    <PlaceObject area="alles">  
    <Textblock>
        <Paragraph>
        <Value select="header"/>
        </Paragraph>
    </Textblock>
    </PlaceObject>
  </Record>
</Layout>
that’s what I have currently
if I remove the Image element inside the PlaceObject, the PDF gets compiled
Patrick Gundlach
@pgundlach
Feb 14 15:25
Image does not have row and column setting, but these are ignored
You must close the image tag
Marius Räsener
@elmcrest
Feb 14 15:26
oh no!! :D
Patrick Gundlach
@pgundlach
Feb 14 15:26
I suggest to use the validation step before running the program. See https://blog.speedata.de/2017/11/27/version_3_1_11-validierung/
Marius Räsener
@elmcrest
Feb 14 15:26
good hint, thx
Patrick Gundlach
@pgundlach
Feb 14 15:26
Which text editor are you using?
Marius Räsener
@elmcrest
Feb 14 15:26
Visual Studio Code
probably there is a plugin for validation
ok, now the letterhead is rendered
how would I „underlay“ it now to everything?
I’ve tried <Overlay> around all the data rules but didn’t work
Patrick Gundlach
@pgundlach
Feb 14 15:34
(I’ll be away for 2 hours)
Marius Räsener
@elmcrest
Feb 14 15:35
I’m patient :P
Marius Räsener
@elmcrest
Feb 14 15:54
Btw, it works! 👍🏻