in reply to Printing Labels

> the content was relatively static so a Word document

docx is "just" zipped XML, so use your document as a template and type in placeholders for the address details.

If you choose the identifiers for the placeholders uniquely enough, a regex will suffice, to fill in the data after unzipping.

I think this is the easiest and safest "migration path" from your old process. ;)

(I know it's a hack, but it worked for me)

HTH :)

Update

Using unique <IDENTIFIERS> in the word editor should be fine. This can't collide with XML code because <> are escaped to HTML entities. Of course your regex must replace &lt;IDENTIFIERS&gt; then.

This has also the advantage that you can sanity check if placeholders were misspelled or new ones missed.

If I were you I would also fill the placeholders to the visual maximum size.

<_____IDENTIFIERS_____>

Like that you can catch overlong address data.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Printing Labels (updates 2)
by Fletch (Bishop) on Oct 08, 2024 at 15:28 UTC

    This works reasonably well. I've done something similar (Excel / OOffice spreadsheet) pulling the XML guts out, turning that into a TToolkit input file with a companion processing script. Users would run the template through the script with a CSV file of the actual data to create their report which the processor proceeds to zip the substituted template file back into a new zip / sxc / xlsx output file as the finished product.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      My intention was to have a stable process were the "template designer" is using word/libreoffice/etc as a visual editor.

      I just tested my "concept" with LibreOffice, it's doing the job, except....

      ... sometimes intermittent <w:...> tags are injected into the placeholder, especially where the underscores are.

      I have to manually mark them and choose "remove formatting" from the menu. I suppose it's word-break information.

      (I can of course also correct it on the source level.)

      So a manual correction is still necessary, if the translator throws errors.

      HTH :)

      Disclaimer: didn't try any other apps like MS Word or Google docs.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

      UPDATE

      here a sample of phantom tags included for a placeholder <___TEST___>

      &lt;</w:t> </w:r> <w:r> <w:rPr> </w:rPr> <w:t> ___TEST___&gt;