Creating Custom Labels

- -

It is a tradition in the UK that the new season's Seville Oranges arrive from Spain in January, starting enthusiasts making marmalade- an essential part of a traditional English breakfast. And an essential part of Paddington Bear's diet.

I had collected empty jam-jars, but realised I had no labels ready. But I did have a collection of sheets of stick-on labels from when I retired from teaching 15 years ago. Time for a bit of LB code-bashing. Actually a variant of a program posted years ago. Yes, I know there are templates in any decent dtp package, and even on-line services. But I like to be unique!

The code is easily adapted to print your desired image(s) and text, and if you want, things like date or even jar number.

The printout is a sheet of labels. If buying label blanks, think what size you want to use and adjust the code appropriately. My example prints a grid of seven rows by two columns,

Notice I do make other jams/chutneys and preserves. And the background image is from a photo in my garden!

-


LB Code ( various versions have all worked well)

    nomainwin

    WindowWidth  =1000
    WindowHeight =1420

    graphicbox#w.g, 0, 0, 1000, 1420
    '   NB Picks up the graphicbox part off-screen. Does NOT if done in a graphic window...

    open "Labeller4" for window_nf as #w

    #w "trapclose quit"

    hw      =hwnd( #w.g)

    calldll #user32, "GetDC",    hw as ulong,  hdc as ulong

    CallDLL #gdi32, "SetBkMode", hdc As ulong, _TRANSPARENT As long, RESULT As long

    loadbmp "scr", "flowers3.bmp"

    call grid 10, 10, 500, 200

    for y = 70 to 1400 step 200
        for x =40 to 1000 step 500
            #w.g "drawbmp scr "; x -24; " "; y -55
            call textPlace  x +120, y     , "255 255   0", 18, "Arial bold", "J&J Jams 2021"
            call textPlace  x +118, y -  2, "255   0   0", 18, "Arial bold", "J&J Jams 2021"

            call textPlace  x +180, y +120, "255 255 255",  8, "Arial", "Date: " +date$()

            call textPlace  x +220, y + 55, "255 255 255", 24, "Arial bold", "Rhubarb"
        next x
    next y

    #w.g "flush"
    #w.g "getbmp s 1 1 1000 1440"
    #w.g "cls ; down ; drawbmp s 1 1 ; flush"
    #w.g "print 1000"

    wait

sub textPlace x, y, colour$, size, font$, t$
    #w.g "color "; colour$
    #w.g "font "; font$; " "; size
    #w.g "up ; goto "; x; " "; y; " ; down"
    #w.g "\"; t$
end sub

sub grid xo, yo, xs, ys
    for x =xo to 1000 step xs
        #w.g "up   ; goto "; x; "    0"
        #w.g "down ; goto "; x; " 1420"
    next x
    for y =yo to 1420 step ys
        #w.g "up   ; goto ";    0; " "; y
        #w.g "down ; goto "; 1420; " "; y
    next y
end sub

sub quit h$
    calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, result as long
    close #w
    end
end sub