Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method to set width of a barcode on Printer #114

Merged
merged 1 commit into from
Apr 25, 2016

Conversation

longsview
Copy link

This method allows a user to set the element width of the barcode which is handy when printing long barcodes.

@longsview longsview mentioned this pull request Apr 20, 2016
mike42 added a commit that referenced this pull request Apr 23, 2016
- Add tests
- Add to README.md
- Add to contributors
- Update example to include widths
- Update default to match initialised printer.
@mike42 mike42 added this to the 1.3 milestone Apr 23, 2016
@mike42
Copy link
Owner

mike42 commented Apr 23, 2016

Thanks for your contribution. I've made some additions to the new feature, and this pull request will be merged to master when the next release is made.

The additions I made are linked to this pull request:

  • Wrote test cases over the new function
  • Added the new function to the README
  • Updated the barcode example to show how it's used
  • Added you to the contributors file
  • Edited the default bar width from 2 to 3, which appears to be consistent with the width of a barcode on a newly-initialised printer

To illustrate, the example snippet is:

/* Height and width */
$printer->selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH);
$printer->text("Height and bar width\n");
$printer->selectPrintMode();
$heights = array(1, 2, 4, 8, 16, 32);
$widths = array(1, 2, 3, 4, 5, 6, 7, 8);
$printer -> text("Default look\n");
$printer->barcode("ABC", Printer::BARCODE_CODE39);

foreach($heights as $height) {
    $printer -> text("\nHeight $height\n");
    $printer->setBarcodeHeight($height);
    $printer->barcode("ABC", Printer::BARCODE_CODE39);
}
foreach($widths as $width) {
    $printer -> text("\nWidth $width\n");
    $printer->setBarcodeWidth($width);
    $printer->barcode("ABC", Printer::BARCODE_CODE39);
}
$printer->feed();

Which presents this output:

barcode-width-snippet

@mike42 mike42 merged commit a368cad into mike42:master Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants