berteh / ScribusGenerator

Create beautiful documents with data. Open source pdf (and Scribus) template and mail-merge alternative.
http://berteh.github.io/ScribusGenerator/
MIT License
246 stars 37 forks source link

PDF annotation data only correct on first record on a page #232

Open garydale opened 1 month ago

garydale commented 1 month ago

I have a two-line repeating format that pulls data from a .csv file. There are 19 repeating sections. The regular text frames contain the correct data, but the PDF annotations only contain the correct information for the first line. All subsequent annotations contain the data from the last record on the page. I'm not sure if that is a coincidence or is an artifact of how I copied the sections.

The information in the text frames is: Position, Incumbent, e-mail address, telephone

The information in the PDF annotations is: e-mail address, telephone.

The annotation information uses the same fields as the text data. The annotations sit on top of the text frames so a click or tap should trigger them. The annotation fields for the e-mail link are named "Text5", "Copy of Text5", "Copy of Text5 (2)" .... by scribus while the telephone links are named "Text6", "Text26", Text29" ...

I use the same technique for other templates that don't use so many repeating formats on a page and they work.

I use this to generate different sections of a larger document, using a command line script. The active line is:

/usr/bin/python3 ~/.scribus/scripts/ScribusGenerator-master/ScribusGeneratorCLI.py ~/.scribus/templates/${1}.sla -c ./Directory/${1}.csv -o ./Directory/ -n ${2}-$((${2}+1))\ ${1} -m

where $1 is the section I am generating, which also specifies the template file and .csv file. $2 is the current year.

I had been using an older version of the generator that used -python3 as the main folder but just downloaded the latest version that uses -master as the main folder. The problem is similar in both of them, but the -python3 version picked up a different e-mail address than the -master version. Both selected the same telephone number.

To repeat, the first instance works while all subsequent instances have the same incorrect pdf annotations that seem to be from much further down in the .csv file.

I am creating a single .sla file.

berteh commented 1 month ago

Hello Gary.

If I understand correctly, your issue seems to me to be related to the location of the pdfannotations bits (XML Element) in the SLA template.. like they would all be located at the end of the source file after the last NEXT-RECORD tag.

Do you mind attaching your (template) sla here so I can have a look?

Did you create all the annotations after duplicating the repeat sections, or were they already defined on the first section and then duplicated along with it?

A priori, changing the location of the pdfannotations XML Element in the SLA, before their respective NEXT-RECORD tag, should solve the issue. But I don't know a sure way to do it in Scribus : last tried with 'grouping' to no avail, maybe 'select and send backwards' would work. I'd do it with an external text/XML editor. In a copy of the template just to be sure :)

Good luck. Berteh

berteh commented 1 month ago

no problem on my end, as in the attached files.

The way I created my template is as suggested in the https://github.com/berteh/ScribusGenerator/wiki/How-to-use-%25SG_NEXT-RECORD%25 :

annotations.zip annotations__single.pdf