2

I'm using Scribus to print labels with serial numbers for my devices. Is there a way that I can automatically read and insert the serial numbers I want to print into Scribus from a text file (or even a Google doc)?

The idea is the following: I define fields in Scribus , and autopopulate the values of this fields form a text file.

Is this possible?

3 Answers 3

2

I used python to edit the file.

    #!/usr/bin/python
    # this script populates the scribus template for the SN of FuelSpy
    # Olmo Mezger
    import re # regular expression
    import os.path #for os path operations

    #config
    myFile_Tempate = "SN_Template.sla"
    myFile_Out = "SN_Tier_01.sla"

    i_start = 1
    i_number = 27*7

    # check if file exists
    if os.path.isfile(myFile_Out):
        print 'aborting, output file exist and I dont want to overwrite it. Delete it manually if you want to continue',
        #quit()
    else:
        print 'continue'

    #
    f_in = open(myFile_Tempate, 'r')
    f_out =open(myFile_Out, 'w')

    # loop
    i = i_start
    for line in f_in:
        #print line
        myString = line
        if myString.find('%') == -1: # it does not have %
            f_out.write(myString)   
        else:
            myNumber = '%0*d' % (4, i)
            myNewString = myString.replace('%',myNumber)
            #print myNewString
            f_out.write(myNewString)
            print i
            i = i+1



    f_in.close()
    f_out.close()
    print "done"
1

There is also Scribus Generator that takes data from a CSV file and replaces variables inside Scribus documents. See http://wiki.scribus.net/canvas/Scribus_Generator

1
  • If I only knew this before... thanks, but my script is working pretty well :-)
    – otmezger
    Commented Mar 10, 2013 at 8:08
0

Scribus ITEXT read

ReadSerial.ps1:

$xmldata=[xml](gc 'C:\1\menu_template1.sla')
($xmldata.SelectNodes("/SCRIBUSUTF8NEW/DOCUMENT/PAGEOBJECT[@ANNAME='Text1232']/ITEXT/@CH")).itemof(0)."#text"

output:

Tested number

WriteSerial.ps1:

$xmldata=[xml](gc 'C:\1\menu_template1.sla')
$xmldata.SelectNodes("/SCRIBUSUTF8NEW/DOCUMENT/PAGEOBJECT[@ANNAME='Text1232']/ITEXT") | Set-Variable xmlnode

$xmlnode.SetAttribute("CH", "New Serial")
$xmldata.Save('C:\1\menu_template1.sla')

Scribus ITEXT write

1
  • Thank you for your answer. I made a python script for this task. You brought me to the idea that the file format is xml, so I can actually edit it via python. Here is my script:
    – otmezger
    Commented Feb 16, 2013 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .