Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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

share|improve this answer
    
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 Feb 16 '13 at 12:29
add comment
up vote 1 down vote accepted

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"
share|improve this answer
add comment

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

share|improve this answer
    
If I only knew this before... thanks, but my script is working pretty well :-) –  otmezger Mar 10 '13 at 8:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.