Printing Avery Labels - 65 per page

I found myself needing to print labels recently (the Avery self-adhesive type, 65 per page) but the HELP isn’t very helpful. I have battled with this task in the past without success but the solution is oh-so-simple, I hope it helps someone else.

There are two golden nuggets in the HELP to note:

  1. Delete all report sections, except the Detail
  2. Set Detail height and width to the label size

I move the DETAIL around the page positioning it for each of 65 labels in turn then issue a Print(RPT:Detail)

I resize the DETAIL as well, so point 2 above isn’t fixed in stone.

The code sample below uses my own data queue “Q”, you’ll need to provide your own.


PrintLabels   PROCEDURE

i                 LONG
dwTopMargin       LONG(480)               ! my laser & inkjet printers need a different top margin
dwLeftMargin      LONG(197)               ! my laser & inkjet printers need a different left hand margin
dwLabelWidth      LONG(1500)              ! Avery Label = 38.1mm wide => 1500 thous inch
dwLabelHeight     LONG(835)               ! Avery Label = 21.2mm tall => 835 thous inch
dwColumnSpace     LONG(84)                ! Avery Label inter column space = 84 thous inch
byColumn          BYTE(1)
byRow             BYTE(1)

Report            REPORT,AT(0,0,1500,840),FONT('Arial',10,,FONT:regular,CHARSET:ANSI),PRE(RPT),PAPER(PAPER:A4),THOUS
Detail               DETAIL,AT(0,0,1500,835),USE(?Detail),ABSOLUTE
                        BOX,AT(0,0,1500,835),USE(?BOX1),COLOR(0E0E0E0H),FILL(0E0E0E0H),LINEWIDTH(1)
                        STRING(@s20),AT(104,62,1302,156),USE(Q.szManSN),TRN,FONT(,8)
                        STRING(@s8),AT(104,250,,167),USE(Q.szPrefixNo),TRN
                        STRING(@s12),AT(104,427,1271,292),USE(Q.szBarCode),TRN,FONT('Code 3 de 9',18,,,CHARSET:SYMBOL)
                     END
                  END
      
   CODE     
      !-- Set the Printer
      !-- Printer{PROPPrint:Device} = myPrinter.szTargetPrinter
                            
      !-- Print Now
      !--
      Open(Report)
      
      SETTARGET(Report)
      
      LOOP i = 1 to RECORDS(Q)
         GET(Q,i)
         if ~ERRORCODE()

            !-- Printing the box during testing is helpful for visual alignment purposes..
            !--          
            !-- IF i % 2 = 0 then HIDE(?BOX1) ELSE UNHIDE(?BOX1).
            
            !-- Set the position for "Absoloute" printing
            !--                                                            
            REPORT$?Detail{PROP:Xpos} = dwLeftMargin + ((byColumn-1) * dwLabelWidth)+ ((byColumn-1) * dwColumnSpace)
            REPORT$?Detail{PROP:Ypos} = dwTopMargin + ((byRow-1) * dwLabelHeight) 
            REPORT$?Detail{PROP:Height} = dwLabelHeight
            
            !-- Now Print the Detail ..
            !--
            Print(RPT:Detail)
            
            !-- Increment column and row counters.. 
            !--
            if byColumn < 5 
               byColumn += 1
            ELSE 
               byColumn = 1
               byRow += 1
            .

            !-- Formfeed?
            !-- Issue an ENDPAGE if this is label 65 and there are more to follow
            !-- if i % 65 = 0 
            !--  ENDPAGE(REPORT)
            !--  byRow = 1
            !--  byColumn = 1
            !-- .
         .
      .     
      Close(Report)

If you allow ?BOX1 to print during testing you can tweak dwTopMargin and dwLeftMargin to achieve perfect alignment.

Mission accomplished !

1 Like

Maybe a 3rd nugget to mention … the DETAIL needs the ABSOLUTE attribute so you can position X,Y on the page, else it prints following the last detail.

I have a Report Test hand code source project that helps figure this kind of stuff out and test it quickly.

1 Like

It’s been a lot of years since I’ve created labels for reports, but I’m pretty sure I just sized the detail so that it fit the label, then let the natural wrapping occur based on the width/height of the detail itself.
Without ABSOLUTE, Clarion will print the detail horizontally until it runs out of page width, and it will automatically progress to the next page.

OTOH, using ABSOLUTE has its uses too, and you can more easily change the order of print to by column or by row. But you also have to handle the endpage.

That is another way I have done it also i.e. a DETAIL with a Width smaller than the Report Width will print side-by-side.

Ditto.
Found an old app that took exactly that approach for Avery 5160 labels.
And incorporated Lee White’s “nudge” code to fine tune position to line up with labels in the printer.

Avery5160