C4::Labels::Layout -A class for creating and manipulating layout objects in Koha


This module provides methods for creating, retrieving, and otherwise manipulating label layout objects used by Koha to create and export labels.



    Invoking the I<new> method constructs a new layout object containing the default values for a layout.
    The following parameters are optionally accepted as key => value pairs:

        C<barcode_type>         Defines the barcode type to be used on labels. NOTE: At present only the following barcode types are supported in the label creator code:
. CODE39 = Code 3 of 9
. CODE39MOD = Code 3 of 9 with modulo 43 checksum
. CODE39MOD10 = Code 3 of 9 with modulo 10 checksum
. COOP2OF5 = A variant of 2 of 5 barcode based on NEC's "Process 8000" code
. INDUSTRIAL2OF5 = The standard 2 of 5 barcode (a binary level bar code developed by Identicon Corp. and Computer Identics Corp. in 1970)
        C<printing_type>        Defines the general layout to be used on labels. NOTE: At present there are only five printing types supported in the label creator code:
. BIB = Only the bibliographic data is printed
. BARBIB = Barcode proceeds bibliographic data
. BIBBAR = Bibliographic data proceeds barcode
. ALT = Barcode and bibliographic data are printed on alternating labels
. BAR = Only the barcode is printed
        C<layout_name>          The descriptive name for this layout.
        C<guidebox>             Setting this to '1' will result in a guide box being drawn around the labels marking the edge of each label
        C<font>                 Defines the type of font to be used on labels. NOTE: The following fonts are available by default on most systems:
. TR = Times-Roman
. TB = Times Bold
. TI = Times Italic
. TBI = Times Bold Italic
. C = Courier
. CB = Courier Bold
. CO = Courier Oblique (Italic)
. CBO = Courier Bold Oblique
. H = Helvetica
. HB = Helvetica Bold
. HBO = Helvetical Bold Oblique
        C<font_size>            Defines the size of the font in postscript points to be used on labels
        C<callnum_split>        Setting this to '1' will enable call number splitting on labels
        C<text_justify>         Defines the text justification to be used on labels. NOTE: The following justification styles are currently supported by label creator code:
. L = Left
. C = Center
. R = Right
        C<format_string>        Defines what fields will be printed and in what order they will be printed on labels. These include any of the data fields that may be mapped
                                to your MARC frameworks. Specify MARC subfields as a 4-character tag-subfield string: ie. 254a Enclose a whitespace-separated list of fields
                                to concatenate on one line in double quotes. ie. "099a 099b" or "itemcallnumber barcode" Static text strings may be entered in single-quotes:
                                ie. 'Some static text here.'

        C<my $layout = Layout->new(); # Creates and returns a new layout object>

        C<my $layout = C4::Labels::Layout->new(barcode_type => 'CODE39', printing_type => 'BIBBAR', font => 'C', font_size => 6); # Creates and returns a new layout object using
            the supplied values to override the defaults>

    B<NOTE:> This layout is I<not> written to the database until save() is invoked. You have been warned!

retrieve(layout_id => layout_id)

    Invoking the I<retrieve> method constructs a new layout object containing the current values for layout_id. The method returns a new object upon success and 1 upon failure.
    Errors are logged to the Apache log.

        C<my $layout = Layout->retrieve(layout_id => 1); # Retrieves layout record 1 and returns an object containing the record>


    Invoking the delete method attempts to delete the layout from the database. The method returns 0 upon success and -1 upon failure. Errors are logged to the Apache log.
    NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that template from the database. See the example below.

        C<my $exitstat = $layout->delete(); # to delete the record behind the $layout object>
        C<my $exitstat = Layout->delete(layout_id => 1); # to delete layout record 1>


    Invoking the I<save> method attempts to insert the layout into the database if the layout is new and update the existing layout record if the layout exists.
    The method returns the new record id upon success and -1 upon failure (This avoids conflicting with a record id of 1). Errors are logged to the Apache log.

        C<my $exitstat = $layout->save(); # to save the record behind the $layout object>


    Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.

        C<my $value = $layout->get_attr($attribute);>

set_attr(attribute => value, attribute_2 => value)

    Invoking the I<set_attr> method will set the value of the supplied attributes to the supplied values. The method accepts key/value pairs separated by

        C<$layout->set_attr(attribute => value);>


    Invoking the I<get_text_wrap_cols> method will return the number of columns that can be printed on the label before wrapping to the next line.

        C<my $text_wrap_cols = $layout->get_text_wrap_cols();>


Chris Nighswonger <cnighswonger AT foundations DOT edu>


Copyright 2009 Foundations Bible College.


This file is part of Koha.

Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.