<<

NAME

C4::Labels::Label - A class for creating and manipulating label objects in Koha

ABSTRACT

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

METHODS

new()

    Invoking the I<new> method constructs a new label object containing the supplied values. Depending on the final output format of the label data
    the minimal required parameters change. (See the implimentation of this object type in labels/label-create-pdf.pl and labels/label-create-csv.pl
    and labels/label-create-xml.pl for examples.) The following parameters are optionally accepted as key => value pairs:

        C<batch_id>             Batch id with which this label is associated
        C<item_number>          Item number of item to be the data source for this label
        C<height>               Height of this label (All measures passed to this method B<must> be supplied in postscript points)
        C<width>                Width of this label
        C<top_text_margin>      Top margin of this label
        C<left_text_margin>     Left margin of this label
        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 varient 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)
. EAN13 = The standard EAN-13 barcode
        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<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<text_wrap_cols>       Defines the column after which the text will wrap to the next line.

get_label_type()

   Invoking the I<get_label_type> method will return the printing type of the label object.

   example:
        C<my $label_type = $label->get_label_type();>

get_attr($attribute)

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

    example:
        C<my $value = $label->get_attr($attribute);>

create_label()

    Invoking the I<create_label> method generates the text for that label and returns it as an arrayref of an array contianing the formatted text as well as creating the barcode
    and writing it directly to the pdf stream. The handling of the barcode is not quite good OO form due to the linear format of PDF::Reuse::Barcode. Be aware that the instantiating
    code is responsible to properly format the text for insertion into the pdf stream as well as the actual insertion.

    example:
        my $label_text = $label->create_label();

draw_label_text()

    Invoking the I<draw_label_text> method generates the label text for the label object and returns it as an arrayref of an array containing the formatted text. The same caveats
    apply to this method as to C<create_label()>. This method accepts the following parameters as key => value pairs: (NOTE: The unit is the postscript point - 72 per inch)

        C<llx>                  The lower-left x coordinate for the text block (The point of origin for all PDF's is the lower left of the page per ISO 32000-1)
        C<lly>                  The lower-left y coordinate for the text block
        C<top_text_margin>      The top margin for the text block.
        C<line_spacer>          The number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size)
        C<font>                 The font to use for this label. See documentation on the new() method for supported fonts.
        C<font_size>            The font size in points to use for this label.
        C<justify>              The style of justification to use for this label. See documentation on the new() method for supported justification styles.

    example:
       C<my $label_text = $label->draw_label_text(
                                                llx                 => $text_llx,
                                                lly                 => $text_lly,
                                                top_text_margin     => $label_top_text_margin,
                                                line_spacer         => $text_leading,
                                                font                => $text_font,
                                                font_size           => $text_font_size,
                                                justify             => $text_justification,
                        );>

barcode()

    Invoking the I<barcode> method generates a barcode for the label object and inserts it into the current pdf stream. This method accepts the following parameters as key => value
    pairs (C<barcode_data> is optional and omitting it will cause the barcode from the current item to be used. C<barcode_type> is also optional. Omission results in the barcode
    type of the current template being used.):

        C<llx>                  The lower-left x coordinate for the barcode block (The point of origin for all PDF's is the lower left of the page per ISO 32000-1)
        C<lly>                  The lower-left y coordinate for the barcode block
        C<width>                The width of the barcode block
        C<y_scale_factor>       The scale factor to be applied to the y axis of the barcode block
        C<barcode_data>         The data to be encoded in the barcode
        C<barcode_type>         The barcode type (See the C<new()> method for supported barcode types)

    example:
       C<$label->barcode(
                    llx                 => $barcode_llx,
                    lly                 => $barcode_lly,
                    width               => $barcode_width,
                    y_scale_factor      => $barcode_y_scale_factor,
                    barcode_data        => $barcode,
                    barcode_type        => $barcodetype,
        );>

csv_data()

    Invoking the I<csv_data> method returns an arrayref of an array containing the label data suitable for passing to Text::CSV_XS->combine() to produce csv output.

    example:
        C<my $csv_data = $label->csv_data();>

AUTHOR

Mason James <mason@katipo.co.nz>

Chris Nighswonger <cnighswonger AT foundations DOT edu>

COPYRIGHT

Copyright 2006 Katipo Communications.

Copyright 2009 Foundations Bible College.

LICENSE

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.

DISCLAIMER OF WARRANTY

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.

<<