The Header: Enauts Thinking!
created:Wed 01 Sep 2021
edited:Wed 01 Sep 2021
translations: english deutsch

Koha: Increase barcode size in labels

When printing the labels for books the barcode is smaller than expected. It does not cover the width of the page and is left-aligned. This is a note to my future self and maybe to someone else how the barcodesize can be increased.

Unfortunately there does not seem to be a setting to change the barcode size - so this has to be done in code.

The relevant code is in /usr/share/koha/lib/C4/Labels/ . You will find, at the lines 220-260, 4 fuctions corresponding to the print types BIB BAR BIBBAR BARBIB. Depending on what you are using you can change only that function or you just change all of them.

Those functions define a barcode width witch is multiplied by 0.8 remove that factor or adjust it to your liking. for me the resulting BIBBAR function looks like:

sub _BIBBAR {
    my $self = shift;
    my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'};
    my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'}; 
    my $barcode_width = 1.0 * $self->{'width'}; 
    my $barcode_y_scale_factor = 0.012 * $self->{'height'};
    my $line_spacer = ($self->{'font_size'} * 1); 
    my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'}));
    $debug and warn  "Label: llx $self->{'llx'}, lly $self->{'lly'}, Text: lly $text_lly, $line_spacer, Barcode: llx $barcode_llx, lly $barcode_lly, $barcode_width, $barcode_y_scale_factor\n";
    return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;


Add a new comment

Note that all comments are moderated - so your post will not appear till I find time to accept it.

The comments do use markup syntax.

Confirm Email: leave the above line empty!