Land Use Public Notification 10.2 - Second Page+ of Avery Labels Different Font Size

2242
1
09-09-2013 11:24 AM
JeremyWilliams
New Contributor II
This isn't a super serious issue, but I have found that when generating 5160 labels over one page, that the second and following pages sizes the font to 9 whereas the first page is size 8.

I opened the code for the avery label and noticed that for the 5160 labels it specifies font size 9 once, but everwhere else in the code it specifies to use size 8.  I changed the 9 to an 8, republished the service and it was good to go.

Here is the final result for the Avery generation python:


from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
import arcpy,os
import textwrap


outfile = arcpy.GetParameterAsText(2).replace("\\",os.sep) #Get the path of the output File
out_pdf = canvas.Canvas(outfile, pagesize = letter)#set the size as letter
out_pdf.setFont("Helvetica", 8)#set the font as Helvetica & size as 8

arcpy.AddMessage("Starting...")#shows the message on the dialog box
arcpy.AddMessage(outfile)#shows the name of the pdf file on the dialog box

Label_name=arcpy.GetParameter(0) #Get the type of the label

arcpy.AddMessage(Label_name)

addressInput = arcpy.GetParameterAsText(1) #Get the address or some text
arcpy.AddMessage(addressInput)

#Logic for averyLabel 5160
def avery5160():
    addressItem = addressInput.split('$')

    hs = 0.25 # Left side of labels
    vs = 10.4

    horizontal_start = hs * inch # staring point of label horizontally
    vertical_start = vs * inch #starting point of label vertically
    count = 0           #initially the count is 0

    for item in addressItem:

        if count > 0 and count % 30 == 0:
            out_pdf.showPage()
            out_pdf.setFont("Helvetica", 8)

            horizontal_start = hs * inch
            vertical_start = vs * inch

        elif count > 0 and count % 10 == 0:
            horizontal_start = horizontal_start + 2.875 *inch # Left side of text in 2nd and 3rd columns of labels
            vertical_start = vs * inch

        label = out_pdf.beginText()
        label.setTextOrigin(horizontal_start, vertical_start)

        details = item.split('~')

        for detail in details:
            if len(detail) > 45:
                name = detail[0:44]
                label.textLine(name)
                name = detail[44:60]
                label.textLine(name)
            else:
                label.textLine(detail)

        out_pdf.drawText(label)

        vertical_start = vertical_start - 1.05 * inch
        count = count + 1

    out_pdf.showPage()
    out_pdf.save()

#Logic for averyLabel 5193
def avery5193():
    addressItem = addressInput.split('$')
    horizontal_start = 0.44 * inch #staring point of label horizontally
    vertical_start =10.45 * inch #starting point of label vertically
    count = 0          #initially the count is 0

    for item in addressItem:

        if count > 0 and count % 24 == 0:
            out_pdf.showPage()
            out_pdf.setFont("Helvetica", 8)

            horizontal_start = 0.44 * inch
            vertical_start = 10.45 * inch
        elif count > 0 and count % 6 == 0:
            horizontal_start = horizontal_start + 2.00 *inch
            vertical_start =10.45 * inch
            print item

        label = out_pdf.beginText()
        label.setTextOrigin(horizontal_start, vertical_start)

        details = item.split('~')

        for detail in details:
            if len(detail) > 25:
                name = detail[0:24]
                label.textLine(name)
                name = detail[24:45]
                label.textLine(name)

            else:
                label.textLine(detail)

        out_pdf.drawText(label)

        vertical_start = vertical_start - 1.7 * inch
        count = count + 1

    out_pdf.showPage()
    out_pdf.save()

#Calling of either one of the Label
if (Label_name=="avery5160"):
    avery5160()
elif (Label_name=="avery5193"):
    avery5193()
0 Kudos
1 Reply
AllisonMuise
New Contributor III
Thanks for pointing this out, Jeremy! I'll fix this in the next release of the tools.

-Allison
0 Kudos