示例#1
0
    def addWatermark(self):
        '''Create a Draft watermark layer. This was taken from:
			http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document'''

        L = len(self.watermark)  # The length of the word
        # will determine the font size
        scribus.defineColor("gray", 11, 11, 11, 11)  # Set your own color here

        u = scribus.getUnit()  # Get the units of the document
        al = scribus.getActiveLayer()  # Identify the working layer
        scribus.setUnit(
            scribus.UNIT_MILLIMETERS)  # Set the document units to mm,
        (w, h) = scribus.getPageSize()  # needed to set the text box size

        scribus.createLayer("c")
        scribus.setActiveLayer("c")

        T = scribus.createText(w / 6, 6 * h / 10, h,
                               w / 2)  # Create the text box
        scribus.setText(self.watermark, T)  # Insert the text
        scribus.setTextColor("gray", T)  # Set the color of the text
        scribus.setFontSize(
            (w / 210) * (180 - 10 * L),
            T)  # Set the font size according to length and width

        scribus.rotateObject(45, T)  # Turn it round antclockwise 45 degrees
        scribus.setUnit(u)  # return to original document units
        # FIXME: It would be nice if we could move the watermark box down to the lowest layer so
        # that it is under all the page text. Have not found a method to do this. For now we just
        # plop the watermark on top of everything else.
        scribus.setActiveLayer(al)  # return to the original active layer
示例#2
0
    def addWatermark (self) :
        '''Create a Draft watermark layer. This was taken from:
            http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document'''

        L = len(self.watermark)                         # The length of the word 
                                                        # will determine the font size
        scribus.defineColor("gray", 11, 11, 11, 11)     # Set your own color here

        u  = scribus.getUnit()                          # Get the units of the document
        al = scribus.getActiveLayer()                   # Identify the working layer
        scribus.setUnit(scribus.UNIT_MILLIMETERS)       # Set the document units to mm,
        (w,h) = scribus.getPageSize()                   # needed to set the text box size

        scribus.createLayer("c")
        scribus.setActiveLayer("c")

        T = scribus.createText(w/6, 6*h/10 , h, w/2)    # Create the text box
        scribus.setText(self.watermark, T)              # Insert the text
        scribus.setTextColor("gray", T)                 # Set the color of the text
        scribus.setFontSize((w/210)*(180 - 10*L), T)    # Set the font size according to length and width

        scribus.rotateObject(45, T)                     # Turn it round antclockwise 45 degrees
        scribus.setUnit(u)                              # return to original document units
# FIXME: It would be nice if we could move the watermark box down to the lowest layer so 
# that it is under all the page text. Have not found a method to do this. For now we just
# plop the watermark on top of everything else.
        scribus.setActiveLayer(al)                      # return to the original active layer
示例#3
0
def addLogo(x, y, isBlack):
    #square side
    a=5
    #line
    line=0.01
    #angle
    angle=15
    #LightGrey
    scribus.defineColor("LightGrey",0,0,0,128)
    #DarkGrey
    scribus.defineColor("DarkGrey",0,0,0,192)
    
    # White cards colors
    squareColor1="Black"
    lineColor1="White"
    squareColor2="DarkGrey"
    lineColor2="White"
    squareColor3="LightGrey"
    lineColor3="White"
    titleColor="Black"
    
    # Black cards colors
    if isBlack==True:
        squareColor1="DarkGrey"
        lineColor1="DarkGrey"
        squareColor2="LightGrey"
        lineColor2="LightGrey"
        squareColor3="White"
        lineColor3="White"
        titleColor="White"
    
    square1=scribus.createRect(x, y+a/10, a, a)
    scribus.setLineWidth(1, square1)
    scribus.setFillColor(squareColor1, square1)
    scribus.setLineColor(lineColor1, square1)
    scribus.rotateObject(angle, square1)
    
    square2=scribus.createRect(x+a/2, y, a, a)
    scribus.setLineWidth(1, square2)
    scribus.setFillColor(squareColor2, square2)
    scribus.setLineColor(lineColor2, square2)
    
    square3=scribus.createRect(x+a, y, a, a)
    scribus.setLineWidth(1, square3)
    scribus.setFillColor(squareColor3, square3)
    scribus.setLineColor(lineColor3, square3)
    scribus.rotateObject(-angle, square3)
    
    title=scribus.createText(x+10,y+2, 50, 5)
    scribus.setFont("Arial Bold", title)
    scribus.setFontSize(8, title)
    scribus.insertText("Game of Filth", 0, title)
    scribus.setTextColor(titleColor, title)
    return
示例#4
0
def addLogo(x, y, isBlack):
    #square side
    a=5
    #line
    line=0.01
    #angle
    angle=15
    #LightGrey
    scribus.defineColor("LightGrey",0,0,0,128)
    #DarkGrey
    scribus.defineColor("DarkGrey",0,0,0,192)
    
    # White cards colors
    squareColor1="Black"
    lineColor1="White"
    squareColor2="DarkGrey"
    lineColor2="White"
    squareColor3="LightGrey"
    lineColor3="White"
    titleColor="Black"
    
    # Black cards colors
    if isBlack==True:
        squareColor1="DarkGrey"
        lineColor1="DarkGrey"
        squareColor2="LightGrey"
        lineColor2="LightGrey"
        squareColor3="White"
        lineColor3="White"
        titleColor="White"
    
    square1=scribus.createRect(x, y+a/10, a, a)
    scribus.setLineWidth(1, square1)
    scribus.setFillColor(squareColor1, square1)
    scribus.setLineColor(lineColor1, square1)
    scribus.rotateObject(angle, square1)
    
    square2=scribus.createRect(x+a/2, y, a, a)
    scribus.setLineWidth(1, square2)
    scribus.setFillColor(squareColor2, square2)
    scribus.setLineColor(lineColor2, square2)
    
    square3=scribus.createRect(x+a, y, a, a)
    scribus.setLineWidth(1, square3)
    scribus.setFillColor(squareColor3, square3)
    scribus.setLineColor(lineColor3, square3)
    scribus.rotateObject(-angle, square3)
    
    title=scribus.createText(x+10,y+2, 50, 5)
    scribus.setFont("Arial Bold", title)
    scribus.setFontSize(8, title)
    scribus.insertText("Cards Against Humanity", 0, title)
    scribus.setTextColor(titleColor, title)
    return
示例#5
0
 def pasteImage(self, src, xpos, ypos, width, height, rotate=False):
     img = scribus.createImage(xpos, ypos, width, height)
     scribus.loadImage(src, img)
     scribus.setScaleImageToFrame(True, True, img)
     scribus.textFlowMode(img, 1)
     if src[-3:] == "jpg":
         scribus.setLineColor("Black", img)
         scribus.setLineWidth(0.2, img)
     #scribus.setLineShade(50,img)
     if rotate:
         scribus.rotateObject(90, img)
     #scribus.setCornerRadius(ROUNDS,img)
     self.imageframes.append(img)
示例#6
0
 def pasteImage(self, src, xpos, ypos, width, height, rotate=False):
    img = scribus.createImage(xpos, ypos, width, height)
    scribus.loadImage(src, img)
    scribus.setScaleImageToFrame(True,True,img)    
    scribus.textFlowMode(img, 1)
    if src[-3:] == "jpg":
       scribus.setLineColor("Black",img)
       scribus.setLineWidth(0.2,img)
    #scribus.setLineShade(50,img)
    if rotate:
       scribus.rotateObject(90,img)
    #scribus.setCornerRadius(ROUNDS,img)
    self.imageframes.append(img)
示例#7
0
def placerandom(iteration):
	for i in range(iteration):
		imagedir = "./elements/"
		random_x = random.randint(-20,int(document_width))
		random_y = random.randint(-20,int(document_height))
		randomsize_x = random.randint(30,50)

		circles = scribus.createImage(random_x, random_y, randomsize_x,randomsize_x)
		scribus.loadImage(imagedir + "ubuntu_circle.png", circles)
		scribus.setScaleImageToFrame(1,1,circles)

		random_degree = random.randint(0,180)
		scribus.rotateObject(random_degree, circles)

		scribus.sentToLayer("randomcircles", circles)
示例#8
0
 def draw(self):
    if self.txt != "":
       if scribus.currentPage() % 2 == 0:   
          r = scribus.createRect(-1,self.y,8,self.height)
          t = scribus.createText(2,self.y + self.height,self.height,6)
       else:   
          (pagewidth, pageheight) = scribus.getPageSize()
          r = scribus.createRect(pagewidth-7,self.y,8,self.height)
          t = scribus.createText(pagewidth-5,self.y + self.height,self.height,6)
       scribus.setFillColor("Black",r)
       scribus.setFillShade(20,r)
       scribus.setLineColor("None",r)
       scribus.setCornerRadius(ROUNDS,r)
       scribus.insertText(self.txt, -1, t)
       scribus.deselectAll()
       scribus.selectObject(t)
       scribus.selectText(0, len(self.txt), t)
       scribus.setStyle("Sidebar", t)
       scribus.rotateObject(90,t)
       self.frames.append(r)
       self.frames.append(t)
示例#9
0
 def draw(self):
     if self.txt != "":
         if scribus.currentPage() % 2 == 0:
             r = scribus.createRect(-1, self.y, 8, self.height)
             t = scribus.createText(2, self.y + self.height, self.height, 6)
         else:
             (pagewidth, pageheight) = scribus.getPageSize()
             r = scribus.createRect(pagewidth - 7, self.y, 8, self.height)
             t = scribus.createText(pagewidth - 5, self.y + self.height,
                                    self.height, 6)
         scribus.setFillColor("Black", r)
         scribus.setFillShade(20, r)
         scribus.setLineColor("None", r)
         scribus.setCornerRadius(ROUNDS, r)
         scribus.insertText(self.txt, -1, t)
         scribus.deselectAll()
         scribus.selectObject(t)
         scribus.selectText(0, len(self.txt), t)
         scribus.setStyle("Sidebar", t)
         scribus.rotateObject(90, t)
         self.frames.append(r)
         self.frames.append(t)
示例#10
0
def placerandom_bars(iteration):
	for i in range(iteration):
		imagedir = "./elements/"
		random_x = random.randint(0,int(document_width))
		random_y = random.randint(0,int(document_height))
		randomsize_x = random.randint(100,105)
		randomsize_y = random.randint(50,50)
	
		bars = scribus.createImage(random_x, random_y, randomsize_x, randomsize_y)
		scribus.loadImage(imagedir + "ubuntu_bar.png", bars)
		scribus.setScaleImageToFrame(1,1,bars)
	
		i = random.randint(0,2)
		if i == 0:
			random_degree = 0
		elif i == 1:
			random_degree = 120
		elif i == 2:
			random_degree = 240	

		scribus.rotateObject(random_degree, bars)
		scribus.sentToLayer("randombars", bars)
示例#11
0
    def main(self):

        # Load up all the file and record information.
        # Use CSV reader to build list of record dicts
        records = self.loadCSVData(self.dataFile)
        totalRecs = len(records)

        # Reality check first to see if we have anything to process
        if totalRecs <= 0:
            scribus.messageBox('Not Found', 'No records found to process!')
            sys.exit()

        pageNumber = 1
        recCount = 0
        row = 0
        pageSide = 'Odd'
        scribus.progressTotal(totalRecs)
        paIndex = {}
        lastName = ''
        firstName = ''
        photoFirstName = ''
        verseRef = ''
        verseText = ''

        # Get the page layout coordinates for this publication
        crds = self.getCoordinates(self.dimensions)

        # Make a new document to put our records on
        if scribus.newDocument(
                getattr(scribus, self.dimensions['page']['scribusPageCode']),
            (self.dimensions['margins']['left'],
             self.dimensions['margins']['right'],
             self.dimensions['margins']['top'],
             self.dimensions['margins']['bottom']), scribus.PORTRAIT, 1,
                scribus.UNIT_POINTS, scribus.NOFACINGPAGES,
                scribus.FIRSTPAGERIGHT, 1):

            self.setPageNumber(crds, pageSide, row, pageNumber)

            while recCount < totalRecs:

                # Output a new page on the first row after we have done the first page
                if row == 0 and recCount != 0:
                    scribus.newPage(-1)
                    if pageSide == 'Odd':
                        pageSide = 'Even'
                    else:
                        pageSide = 'Odd'

                    self.setPageNumber(crds, pageSide, row, pageNumber)

                ########### Now set the current record in the current row ##########

                # Set the last name
                lastName = records[recCount]['NameLast']

                # Adjust the NameFirst field to include the spouse if there is one
                if records[recCount]['Spouse'] != '':
                    firstName = records[recCount][
                        'NameFirst'] + ' & ' + records[recCount]['Spouse']
                else:
                    firstName = records[recCount]['NameFirst']

                # Make the photo file name
                photoFirstName = firstName.replace('&', '-').replace(
                    '.', '').replace(' ', '')

                # Set our record count for progress display and send a status message
                scribus.progressSet(recCount)
                scribus.statusMessage('Placing record ' + ` recCount ` +
                                      ' of ' + ` totalRecs `)

                # Add a watermark if a string is specified
                if self.outputWatermark:
                    self.addWatermark()

                # Put the last name element in this row
                nameLastBox = scribus.createText(crds[row]['nameLastXPos'],
                                                 crds[row]['nameLastYPos'],
                                                 crds[row]['nameLastWidth'],
                                                 crds[row]['nameLastHeight'])
                scribus.setText(lastName, nameLastBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, nameLastBox)
                scribus.setTextDistances(0, 0, 0, 0, nameLastBox)
                scribus.setFont(self.fonts['nameLast']['bold'], nameLastBox)
                scribus.setFontSize(self.fonts['nameLast']['size'],
                                    nameLastBox)
                scribus.setTextShade(80, nameLastBox)
                scribus.rotateObject(90, nameLastBox)

                # Place the first name element in this row
                nameFirstBox = scribus.createText(crds[row]['nameFirstXPos'],
                                                  crds[row]['nameFirstYPos'],
                                                  crds[row]['nameFirstWidth'],
                                                  crds[row]['nameFirstHeight'])
                scribus.setText(records[recCount]['Caption'], nameFirstBox)
                scribus.setTextAlignment(scribus.ALIGN_LEFT, nameFirstBox)
                scribus.setFont(self.fonts['nameFirst']['boldItalic'],
                                nameFirstBox)
                scribus.setFontSize(self.fonts['nameFirst']['size'],
                                    nameFirstBox)

                # Place the image element in this row
                # We will need to do some processing on the first pass
                # The default output format is JPG
                orgImgFileName = records[recCount]['Photo']
                orgImgFile = os.path.join(self.orgImgDir, orgImgFileName)
                baseImgFileName = lastName + '_' + photoFirstName
                if self.willBePngImg:
                    ext = 'png'
                else:
                    ext = 'jpg'
                if not self.rgbColor:
                    imgFile = os.path.join(
                        getattr(self, ext + 'ImgDir'),
                        baseImgFileName + '-gray' + '.' + ext)
                else:
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'),
                                           baseImgFileName + '.' + ext)

                # Process the image now if there is none
                if not os.path.exists(imgFile):
                    self.img_process.sizePic(orgImgFile, imgFile,
                                             self.maxHeight)
                    #                    self.img_process.outlinePic(imgFile, imgFile)
                    self.img_process.scalePic(imgFile, imgFile,
                                              self.imgDensity)
                    self.img_process.addPoloroidBorder(imgFile, imgFile)
                    # Color RGB is the default
                    if not self.rgbColor:
                        self.img_process.makeGray(imgFile, imgFile)

                # Double check the output and substitute with placeholder pic
                if not os.path.exists(imgFile):
                    imgFile = self.placeholderPic
                # Create the imageBox and load the picture
                imageBox = scribus.createImage(crds[row]['imageXPos'],
                                               crds[row]['imageYPos'],
                                               crds[row]['imageWidth'],
                                               crds[row]['imageHeight'])
                if os.path.isfile(imgFile):
                    scribus.loadImage(imgFile, imageBox)
                scribus.setScaleImageToFrame(scaletoframe=1,
                                             proportional=1,
                                             name=imageBox)

                # Place the country element in this row (add second one if present)
                countryBox = scribus.createText(crds[row]['countryXPos'],
                                                crds[row]['countryYPos'],
                                                crds[row]['countryWidth'],
                                                crds[row]['countryHeight'])
                countryLine = records[recCount]['Country1']
                try:
                    if records[recCount]['Country2'] != '':
                        countryLine = countryLine + ' & ' + records[recCount][
                            'Country2']
                except:
                    pass
                scribus.setText(countryLine, countryBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, countryBox)
                scribus.setFont(self.fonts['text']['boldItalic'], countryBox)
                scribus.setFontSize(self.fonts['text']['size'], countryBox)

                # Place the assignment element in this row
                assignBox = scribus.createText(crds[row]['assignXPos'],
                                               crds[row]['assignYPos'],
                                               crds[row]['assignWidth'],
                                               crds[row]['assignHeight'])
                scribus.setText(self.fixText(records[recCount]['Assignment']),
                                assignBox)
                # Assign style to box
                #                scribus.createParagraphStyle(name='assignStyle', alignment=0, leftmargin=10, firstindent=-10)
                #                scribus.setStyle('assignStyle', assignBox)
                # Hard formated box
                scribus.setTextAlignment(scribus.ALIGN_LEFT, assignBox)
                scribus.setFont(self.fonts['text']['italic'], assignBox)
                scribus.setFontSize(self.fonts['text']['size'], assignBox)
                scribus.setLineSpacing(self.fonts['text']['size'] + 1,
                                       assignBox)
                scribus.setTextDistances(4, 0, 0, 0, assignBox)
                # Resize the frame height and determine the difference for
                # placing the next frame below it
                assignHeightNew = self.resizeFrame(assignBox)
                assignHeightDiff = crds[row]['assignHeight'] - assignHeightNew

                # Place the verse element in this row
                verseYPosNew = crds[row]['verseYPos'] - assignHeightDiff
                verseBox = scribus.createText(crds[row]['verseXPos'],
                                              verseYPosNew,
                                              crds[row]['verseWidth'],
                                              crds[row]['verseHeight'])
                # The verse element may be either a Scripture verse or a prayer request
                # If it is Scripture, and it has a verse ref, we want to set that
                # seperatly so we need to do a little preprocess on the text to find
                # out if it has a ref. This script will only recognize references
                # at the end of the string that are enclosed in brackets. See the
                # findVerseRef() function for more details
                verseRef = self.findVerseRef(records[recCount]['Prayer'])
                if verseRef:
                    verseText = self.removeVerseRef(
                        self.fixText(records[recCount]['Prayer']))
                    scribus.setText(verseText, verseBox)
                else:
                    scribus.setText(self.fixText(records[recCount]['Prayer']),
                                    verseBox)
                # Can't find a way to set alignment to justified using setTextAlignment()
#                scribus.setTextAlignment(scribus.ALIGN_LEFT, verseBox)
# Because of this, we make a style which seems to work
                scribus.createParagraphStyle(name='vBoxStyle', alignment=3)
                scribus.setStyle('vBoxStyle', verseBox)
                scribus.setFont(self.fonts['verse']['regular'], verseBox)
                scribus.setFontSize(self.fonts['verse']['size'], verseBox)
                scribus.setLineSpacing(self.fonts['verse']['size'] + 1,
                                       verseBox)
                scribus.setTextDistances(4, 0, 4, 0, verseBox)
                if self.hyphenate:
                    scribus.hyphenateText(verseBox)
                # Get the height difference in case we need to set ref box
                verseHeightNew = self.resizeFrame(verseBox)
                verseHeightDiff = crds[row]['verseHeight'] - verseHeightNew
                if verseRef:
                    # Set coordinates for this box
                    vRefBoxX = crds[row]['verseXPos']
                    vRefBoxY = (verseYPosNew + verseHeightNew)
                    vRefBoxH = crds[row]['nameFirstHeight'] / 2
                    vRefBoxW = crds[row]['verseWidth']
                    verseRefBox = scribus.createText(vRefBoxX, vRefBoxY,
                                                     vRefBoxW, vRefBoxH)
                    scribus.setText(verseRef, verseRefBox)
                    scribus.setTextAlignment(scribus.ALIGN_RIGHT, verseRefBox)
                    scribus.setFont(self.fonts['verse']['italic'], verseRefBox)
                    scribus.setFontSize(self.fonts['verse']['size'] - 2,
                                        verseRefBox)
                    scribus.setLineSpacing(self.fonts['verse']['size'],
                                           verseRefBox)
                    scribus.setTextDistances(2, 0, 0, 0, verseRefBox)

                # Up our counts
                if row >= self.dimensions['rows']['count'] - 1:
                    row = 0
                    pageNumber += 1
                else:
                    row += 1

                recCount += 1

            # Create the index page here
            # Output a new page for the index
            if row == 0 and recCount != 0:
                scribus.newPage(-1)
                if pageSide == 'Odd':
                    pageSide = 'Even'
                else:
                    pageSide = 'Odd'

                self.setPageNumber(crds, pageSide, 0, pageNumber)

        # Outut the index entries at this point
#        for key in paIndex.keys() :

# Report we are done now before we loose focus
        scribus.statusMessage('Process Complete!')

        ###############################################################################
        ############################## Output Results #################################
        ###############################################################################

        # Now we will output the results to PDF if that is desired
        if self.makePdf:
            pdfExport = scribus.PDFfile()
            pdfExport.info = self.pdfFile
            pdfExport.file = self.pdfFile
            pdfExport.save()

        # View the output if set
        if self.makePdf and self.viewPdf:
            cmd = ['evince', self.pdfFile]
            try:
                subprocess.Popen(cmd)
            except Exception as e:
                result = scribus.messageBox(
                    'View PDF command failed with: ' + str(e),
                    scribus.BUTTON_OK)
scribus.newDocument((pageX, pageY), (0.0, 0.0, 0.0, 0.0), scribus.LANDSCAPE, 1, scribus.UNIT_INCHES, scribus.PAGE_1, 0, 1)

#0,13 for final
for x in range(0,13):
	#1,12,6 for final
	for y in range(1,12,6):
		rx = x
		ry = y
		for zx in range(0,2):
			for zy in range(0,3):						
				a = scribus.createText(2.25+((zx+0)*(pageX/1.55)), 0.75+(zy*(pageY/3.84)), 1.25, 0.25)
				scribus.setFont('Arial Regular',a)		
				scribus.setFontSize(12, a)
				scribus.setTextColor("gray", a)
				scribus.setTextAlignment(scribus.ALIGN_CENTERED, a)
				scribus.rotateObject(180, a);
				
				rxy = rx-ry
				scribus.insertText('%(rx)d - %(ry)d = %(rxy)d' % locals(), 0, a)		
				
				q = scribus.createText(1.0+((zx+0)*(pageX/1.55)), 1.125+(zy*(pageY/3.84)), 4, 1)
				scribus.setFont('Arial Regular',q)		
				scribus.setFontSize(55, q)
				scribus.setTextAlignment(scribus.ALIGN_CENTERED, q)
				scribus.insertText('%(rx)d + %(ry)d =' % locals(), 0, q)
				ry = ry + 1
		l = scribus.createLine(0.0,2.833333,11,2.833333)
		scribus.setLineColor("gray", l)
		l = scribus.createLine(0.0,5.666666,11,5.666666)
		scribus.setLineColor("gray", l)
		l = scribus.createLine(5.5,0.0,5.5,8.5)
示例#13
0
    def main (self) :

        # Load up all the file and record information.
        # Use CSV reader to build list of record dicts
        records         = self.loadCSVData(self.dataFile)
        totalRecs       = len(records)

        # Reality check first to see if we have anything to process
        if totalRecs <= 0 :
            scribus.messageBox('Not Found', 'No records found to process!')
            sys.exit()

        pageNumber      = 1
        recCount        = 0
        row             = 0
        pageSide        = 'Odd'
        scribus.progressTotal(totalRecs)
        paIndex         = {}
        lastName        = ''
        firstName       = ''
        photoFirstName  = ''
        verseRef        = ''
        verseText       = ''

        # Get the page layout coordinates for this publication
        crds = self.getCoordinates(self.dimensions)

        # Make a new document to put our records on
        if scribus.newDocument(getattr(scribus, self.dimensions['page']['scribusPageCode']), 
                    (self.dimensions['margins']['left'], self.dimensions['margins']['right'], self.dimensions['margins']['top'], self.dimensions['margins']['bottom']),
                        scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, 
                            scribus.FIRSTPAGERIGHT, 1) :

            self.setPageNumber(crds, pageSide, row, pageNumber)

            while recCount < totalRecs :

                # Output a new page on the first row after we have done the first page
                if row == 0 and recCount != 0:
                    scribus.newPage(-1)
                    if pageSide == 'Odd' :
                        pageSide = 'Even'
                    else :
                        pageSide = 'Odd'

                    self.setPageNumber(crds, pageSide, row, pageNumber)

                ########### Now set the current record in the current row ##########

                # Set the last name
                lastName = records[recCount]['NameLast']

                # Adjust the NameFirst field to include the spouse if there is one
                if records[recCount]['Spouse'] != '' :
                    firstName = records[recCount]['NameFirst'] + ' & ' + records[recCount]['Spouse']
                else :
                    firstName = records[recCount]['NameFirst']
                    
                # Make the photo file name
                photoFirstName = firstName.replace('&', '-').replace('.', '').replace(' ', '')

                # Set our record count for progress display and send a status message
                scribus.progressSet(recCount)
                scribus.statusMessage('Placing record ' + `recCount` + ' of ' + `totalRecs`)

                # Add a watermark if a string is specified
                if self.outputWatermark :
                    self.addWatermark()

                # Put the last name element in this row
                nameLastBox = scribus.createText(crds[row]['nameLastXPos'], crds[row]['nameLastYPos'], crds[row]['nameLastWidth'], crds[row]['nameLastHeight'])
                scribus.setText(lastName, nameLastBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, nameLastBox)
                scribus.setTextDistances(0, 0, 0, 0, nameLastBox)
                scribus.setFont(self.fonts['nameLast']['bold'], nameLastBox)
                scribus.setFontSize(self.fonts['nameLast']['size'], nameLastBox)
                scribus.setTextShade(80, nameLastBox)
                scribus.rotateObject(90, nameLastBox)

                # Place the first name element in this row
                nameFirstBox = scribus.createText(crds[row]['nameFirstXPos'], crds[row]['nameFirstYPos'], crds[row]['nameFirstWidth'], crds[row]['nameFirstHeight'])
                scribus.setText(records[recCount]['Caption'], nameFirstBox)
                scribus.setTextAlignment(scribus.ALIGN_LEFT, nameFirstBox)
                scribus.setFont(self.fonts['nameFirst']['boldItalic'], nameFirstBox)
                scribus.setFontSize(self.fonts['nameFirst']['size'], nameFirstBox)

                # Place the image element in this row
                # We will need to do some processing on the first pass
                # The default output format is JPG
                orgImgFileName = records[recCount]['Photo']
                orgImgFile = os.path.join(self.orgImgDir, orgImgFileName)
                baseImgFileName = lastName + '_' + photoFirstName
                if self.willBePngImg :
                    ext = 'png'
                else :
                    ext = 'jpg'
                if not self.rgbColor :
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'), baseImgFileName + '-gray' + '.' + ext)
                else :
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'), baseImgFileName + '.' + ext)

                # Process the image now if there is none
                if not os.path.exists(imgFile) :
                    self.img_process.sizePic(orgImgFile, imgFile, self.maxHeight)
#                    self.img_process.outlinePic(imgFile, imgFile)
                    self.img_process.scalePic(imgFile, imgFile, self.imgDensity)
                    self.img_process.addPoloroidBorder(imgFile, imgFile)
                    # Color RGB is the default
                    if not self.rgbColor :
                        self.img_process.makeGray(imgFile, imgFile)

                # Double check the output and substitute with placeholder pic
                if not os.path.exists(imgFile) :
                    imgFile = self.placeholderPic
                # Create the imageBox and load the picture
                imageBox = scribus.createImage(crds[row]['imageXPos'], crds[row]['imageYPos'], crds[row]['imageWidth'], crds[row]['imageHeight'])
                if os.path.isfile(imgFile) :
                    scribus.loadImage(imgFile, imageBox)
                scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=imageBox)

                # Place the country element in this row (add second one if present)
                countryBox = scribus.createText(crds[row]['countryXPos'], crds[row]['countryYPos'], crds[row]['countryWidth'], crds[row]['countryHeight'])
                countryLine = records[recCount]['Country1']
                try :
                    if records[recCount]['Country2'] != '' :
                        countryLine = countryLine + ' & ' + records[recCount]['Country2']
                except :
                    pass
                scribus.setText(countryLine, countryBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, countryBox)
                scribus.setFont(self.fonts['text']['boldItalic'], countryBox)
                scribus.setFontSize(self.fonts['text']['size'], countryBox)

                # Place the assignment element in this row
                assignBox = scribus.createText(crds[row]['assignXPos'], crds[row]['assignYPos'], crds[row]['assignWidth'], crds[row]['assignHeight'])
                scribus.setText(self.fixText(records[recCount]['Assignment']), assignBox)
                # Assign style to box
#                scribus.createParagraphStyle(name='assignStyle', alignment=0, leftmargin=10, firstindent=-10)
#                scribus.setStyle('assignStyle', assignBox)
                # Hard formated box
                scribus.setTextAlignment(scribus.ALIGN_LEFT, assignBox)
                scribus.setFont(self.fonts['text']['italic'], assignBox)
                scribus.setFontSize(self.fonts['text']['size'], assignBox)
                scribus.setLineSpacing(self.fonts['text']['size'] + 1, assignBox)
                scribus.setTextDistances(4, 0, 0, 0, assignBox)
                # Resize the frame height and determine the difference for
                # placing the next frame below it
                assignHeightNew = self.resizeFrame(assignBox)
                assignHeightDiff = crds[row]['assignHeight'] - assignHeightNew

                # Place the verse element in this row
                verseYPosNew = crds[row]['verseYPos'] - assignHeightDiff
                verseBox = scribus.createText(crds[row]['verseXPos'], verseYPosNew, crds[row]['verseWidth'], crds[row]['verseHeight'])
                # The verse element may be either a Scripture verse or a prayer request
                # If it is Scripture, and it has a verse ref, we want to set that
                # seperatly so we need to do a little preprocess on the text to find
                # out if it has a ref. This script will only recognize references
                # at the end of the string that are enclosed in brackets. See the
                # findVerseRef() function for more details
                verseRef = self.findVerseRef(records[recCount]['Prayer'])
                if verseRef :
                    verseText = self.removeVerseRef(self.fixText(records[recCount]['Prayer']))
                    scribus.setText(verseText, verseBox)
                else :
                    scribus.setText(self.fixText(records[recCount]['Prayer']), verseBox)
                # Can't find a way to set alignment to justified using setTextAlignment()
#                scribus.setTextAlignment(scribus.ALIGN_LEFT, verseBox)
                # Because of this, we make a style which seems to work
                scribus.createParagraphStyle(name='vBoxStyle', alignment=3)
                scribus.setStyle('vBoxStyle', verseBox)
                scribus.setFont(self.fonts['verse']['regular'], verseBox)
                scribus.setFontSize(self.fonts['verse']['size'], verseBox)
                scribus.setLineSpacing(self.fonts['verse']['size'] + 1, verseBox)
                scribus.setTextDistances(4, 0, 4, 0, verseBox)
                if self.hyphenate :
                    scribus.hyphenateText(verseBox)
                # Get the height difference in case we need to set ref box
                verseHeightNew = self.resizeFrame(verseBox)
                verseHeightDiff = crds[row]['verseHeight'] - verseHeightNew
                if verseRef :
                    # Set coordinates for this box
                    vRefBoxX = crds[row]['verseXPos']
                    vRefBoxY = (verseYPosNew + verseHeightNew)
                    vRefBoxH = crds[row]['nameFirstHeight'] / 2
                    vRefBoxW = crds[row]['verseWidth']
                    verseRefBox = scribus.createText(vRefBoxX, vRefBoxY, vRefBoxW, vRefBoxH)
                    scribus.setText(verseRef, verseRefBox)
                    scribus.setTextAlignment(scribus.ALIGN_RIGHT, verseRefBox)
                    scribus.setFont(self.fonts['verse']['italic'], verseRefBox)
                    scribus.setFontSize(self.fonts['verse']['size'] - 2, verseRefBox)
                    scribus.setLineSpacing(self.fonts['verse']['size'], verseRefBox)
                    scribus.setTextDistances(2, 0, 0, 0, verseRefBox)

                # Up our counts
                if row >= self.dimensions['rows']['count'] - 1 :
                    row = 0
                    pageNumber +=1
                else :
                    row +=1
                    
                recCount +=1

            # Create the index page here
            # Output a new page for the index
            if row == 0 and recCount != 0:
                scribus.newPage(-1)
                if pageSide == 'Odd' :
                    pageSide = 'Even'
                else :
                    pageSide = 'Odd'

                self.setPageNumber(crds, pageSide, 0, pageNumber)

        # Outut the index entries at this point
#        for key in paIndex.keys() :

        # Report we are done now before we loose focus
        scribus.statusMessage('Process Complete!')

###############################################################################
############################## Output Results #################################
###############################################################################

        # Now we will output the results to PDF if that is desired
        if self.makePdf :
            pdfExport =  scribus.PDFfile()
            pdfExport.info = self.pdfFile
            pdfExport.file = self.pdfFile
            pdfExport.save()

        # View the output if set
        if self.makePdf and self.viewPdf :
            cmd = ['evince', self.pdfFile]
            try :
                subprocess.Popen(cmd)
            except Exception as e :
                result = scribus.messageBox ('View PDF command failed with: ' + str(e), scribus.BUTTON_OK)