Bug 14107 - Patron cards: Make barcode width and height scaling editable
Summary: Patron cards: Make barcode width and height scaling editable
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Label/patron card printing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
: 9480 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-05-01 14:08 UTC by Marc Véron
Modified: 2017-04-20 19:24 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 14107 - Patron cards: Make barcode width and height scaling editable (6.56 KB, patch)
2015-05-02 05:50 UTC, Marc Véron
Details | Diff | Splinter Review
Use case "Butterfly" Card (10.69 KB, image/jpeg)
2015-05-02 14:51 UTC, Marc Véron
Details
Output PDF without patch (665.41 KB, application/x-download)
2015-05-02 14:55 UTC, Marc Véron
Details
OutputPDF with patch (665.41 KB, application/x-download)
2015-05-02 14:58 UTC, Marc Véron
Details
new barcode scaling options in patron card creator menue (9.31 KB, image/png)
2015-05-04 20:58 UTC, Heinrich Hartl
Details
[SIGNED OFF] Bug 14107: Patron cards: Make barcode width and height scaling editable (6.63 KB, patch)
2015-05-05 13:04 UTC, Chris Nighswonger
Details | Diff | Splinter Review
Bug 14107: Patron cards: Make barcode width and height scaling editable (6.69 KB, patch)
2015-07-02 13:56 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2015-05-01 14:08:16 UTC

    
Comment 1 Marc Véron 2015-05-02 05:50:50 UTC Comment hidden (obsolete)
Comment 2 Chris Nighswonger 2015-05-02 11:04:14 UTC
This needs to be tested with barcodes of less than 4 digits. The original problem with exposing scaling was that barcode shorter than ability about 5 digits behaved badly. At the time some libraries were starting numbering at 1.
Comment 3 Marc Véron 2015-05-02 14:51:56 UTC
Created attachment 38767 [details]
Use case "Butterfly" Card

Usecase "Butterfly" card. This type of card has a self adhesive part on a sheet of paper (e.g. an invoice) that can be detached and folded.

See follwong attachments (Cards created without and with patch).
Comment 4 Marc Véron 2015-05-02 14:55:51 UTC
Created attachment 38768 [details]
Output PDF without patch

Butterfly card without patch.
Comment 5 Marc Véron 2015-05-02 14:58:29 UTC
Created attachment 38769 [details]
OutputPDF with patch

After applying the patch and adjusting the value for barcode width scaling.
Comment 6 M. Tompsett 2015-05-02 17:43:01 UTC
C4/Patroncards/Patroncard.pm is modified. Is there a way to add tests?
Comment 7 Chris Nighswonger 2015-05-02 17:49:47 UTC
Looks good to me. If it's not done before Monday, I'll be glad to sign-off on it.
Comment 8 Marc Véron 2015-05-02 18:33:18 UTC
(In reply to M. Tompsett from comment #6)
> C4/Patroncards/Patroncard.pm is modified. Is there a way to add tests?

Changing the values has a visual impact on the PDF, I do not know how this could be tested.
Comment 9 Heinrich Hartl 2015-05-04 20:58:50 UTC
Created attachment 38829 [details]
new barcode scaling options in patron card creator menue

The enhancement provided by mveron allows scaling the barcode both in horizontal and vertical direction. The scaling values in the menue are preset with the values that produce the same result as before the the enhancement.
Comment 10 Heinrich Hartl 2015-05-04 21:03:17 UTC
koha manual chapter 3.1.6 on patron card creator needs to be adapted to include the new barcode scaling options
Comment 11 Chris Nighswonger 2015-05-05 13:00:24 UTC
Marc, would it be possible for you to add this to the label tool as well?
Comment 12 Chris Nighswonger 2015-05-05 13:04:12 UTC Comment hidden (obsolete)
Comment 13 Marc Véron 2015-05-05 13:09:59 UTC
(In reply to Chris Nighswonger from comment #11)
> Marc, would it be possible for you to add this to the label tool as well?

Chris, I think so.
Can you open a separate Bug for the label tool and put me on the cc?
Comment 14 Heinrich Hartl 2015-05-15 18:01:23 UTC
I have done a little bit black box analysis: how does the bar code behave under different sized labels/cards. The analysis is done with 3.18.5, hence without this patch or any other modification.

1. The bar code position defines the position of the lower left corner of the bar code string (as designed). The bar code includes a little bit of white lead space, approximately half a code character.Therefore the first black bar of the bar code is found that amount to the right of the defined start position.
2.The length of the bar code string including white lead and trailing space is approximately 75% of the label width. if this observed length is associated with a value 0.8 some extra space is included in the calculation. 
3. The lower left position defined is the baseline of the human readable string. If that string is not printed the height reserved for the human readable string is left blank.
4. the height of human readable string + the bar code is about 27% of the label/card height. The bar code alone is 20% of the label/card height. If these values are associated with an internal scale 0.01 I do not know to which basis this scale is chosen. 14 digits + start char + stop char were measured 49 mm long 7mm high on a template with label/cards 70*36mm close to credit card size 85*54mm. Aspect ratio of bar code letters h/w hence was 7/3 w~0.5*h.

Unfortunately the bar code is the only element of the layout that reacts to the size of the label/card. All text and pictures remain same size and position (with respect to lower left corner) with disregard to the size of the label/card
I think it is desirable to have a consistent and foreseeable behaviour.

May I suggest to think about giving the barcode a height in chosen units and define its (estimated) length from the number of characters in string * character width (derived from height * aspect factor 0,5). It is then the users responsibility to choose a barcode height in the layout which results an acceptable string length not exceeding the available space on the label/card.
Comment 15 Chris Nighswonger 2015-05-15 18:39:58 UTC
The problem with this is that PDF::Barcode does some internal scaling on the image depending on the length of the number, etc. So one ends up chasing ones tail so to speak. The currently proposed solution avoids this effect for the most part.
Comment 16 Jonathan Druart 2015-07-02 13:56:38 UTC
Created attachment 40764 [details] [review]
Bug 14107: Patron cards: Make barcode width and height scaling editable

The size of the barcode in patron card creator was hardcoded to 1% of the card height and 80% of the card width.
This patch exposes both values in the layout editor. If no values are given, the previousely hard coded values (0.01 / 0.8) are used in order to work with existing card definitions.

To test:
- Go to Home > Tools > Patron card creator
- Export a patron card (PDF) from en existing definition
- Apply patch
- Export patron card again, compare results (should be the same)
- Go to Home > Tools > Patron card creator > Manage card layouts
- Edit the layout you use for testing and set barcode scaling values e.g. to 0.03 for height and 0.4 for widht
- Export patron card again, verify that barcode size changed

Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 17 Tomás Cohen Arazi 2015-07-24 17:08:21 UTC
Patch pushed to master.

Thanks Marc!
Comment 18 Tomás Cohen Arazi 2015-07-24 17:13:23 UTC
Patch pushed to master.

Thanks Marc!
Comment 19 Marc Véron 2017-04-20 19:24:51 UTC
*** Bug 9480 has been marked as a duplicate of this bug. ***