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

[Feature]: Fixed Width Barcodes #3955

Open
1 task done
objecttothis opened this issue Mar 25, 2024 · 7 comments
Open
1 task done

[Feature]: Fixed Width Barcodes #3955

objecttothis opened this issue Mar 25, 2024 · 7 comments

Comments

@objecttothis
Copy link
Member

objecttothis commented Mar 25, 2024

Type of Feature

✨ New Feature

OpensourcePOS Version

opensourcepos 3.4.0-dev

Description

The new barcode generator is lightweight and reasonably easy to use, but has one major weakness. It cannot generate fixed width barcodes like the previous library could. It can generate them via BarcodeGeneratorHTMLDynamic which uses DIV's to show the barcode in HTML, however those barcodes don't render when printed. All other barcode generators use a width factor rather than width and they don't expose the getBarcodeData()->getWidth() function (protected), so calculating the widthFactor dynamically isn't possible. We are currently using the BarcodeGeneratorSVG class which generates an inline SVG, and while SVG's are meant to scale, their code is hard-coding the width, so even putting it inside a DIV with CSS doesn't scale it. I created a feature request, but changes are still a ways off and the dev isn't convinced he wants to make fixed width possible due to the complexity added. picqer/php-barcode-generator#195

There are three options

  1. Do nothing and yank with barcode width setting. We could possibly replace it with the widthFactor that picquer uses but this will not make barcodes fixed width.
  2. Extend the BarcodeGeneratorSVG class and which will allow us to access getWidth() and therefore calculate what the widthFactor needs to be in order to get the width we desire. This is fairly straightforward but could postentially have breaking changes with future upgrades to picquer/php-barcode-generator
  3. Wait until they upgrade their library to something that makes this workable. That may never happen though.

Additional Information

No response

Verify you searched open requests in OpensourcePOS

  • I agree I have searched Open Requests
@odiea
Copy link
Collaborator

odiea commented Mar 25, 2024

@objecttothis . This code works for me.
app/controller/config remove sanitize from line 900 - Width
Barcode_lib change line 115 to return $generator->getBarcode($barcode_value, $barcode_config['barcode_type'], $barcode_config['barcode_width'], $barcode_config['barcode_height']);
App/views/configs/barcode_config and change the following to.

<?= form_input ([
						'step' => '.25',
						'max' => '2',
						'min' => '1',

I can now have 5 different barcode widths. Hope i am not comiting a sin here.

@objecttothis
Copy link
Member Author

@objecttothis . This code works for me. app/controller/config remove sanitize from line 900 - Width Barcode_lib change line 115 to return $generator->getBarcode($barcode_value, $barcode_config['barcode_type'], $barcode_config['barcode_width'], $barcode_config['barcode_height']); App/views/configs/barcode_config and change the following to.

<?= form_input ([
						'step' => '.25',
						'max' => '2',
						'min' => '1',

I can now have 5 different barcode widths. Hope i am not comiting a sin here.

It appears that what you are proposing is to use 'barcode_width' as a 'widthFactor'. This doesn't create fixed width barcodes though. For example Code128 type barcodes 9781234567890 and 6000005345 will produce two different width barcodes with your implementation.

@odiea
Copy link
Collaborator

odiea commented Mar 26, 2024

I had a thrift store at one time so the way I think is will it print properly on the Labels and Tags that were being used. Always depended on the software to create a barcode from the Item_id.

@objecttothis
Copy link
Member Author

I had a thrift store at one time so the way I think is will it print properly on the Labels and Tags that were being used. Always depended on the software to create a barcode from the Item_id.

In that respect what we have currently will work just fine. It displays on the screen and it prints. The height is fixed, but the difference from our previous implementation is that the width will vary based on the barcode content length. It most likely won't be a breaking change for anyone. On the upside there are now many more barcode formats supported, including Pharmacy barcodes which I believe has been requested before.

@odiea
Copy link
Collaborator

odiea commented Mar 26, 2024

? The height is fixed, You mean it is already working or it is not adjustable?

@objecttothis
Copy link
Member Author

? The height is fixed, You mean it is already working or it is not adjustable?

Sorry, I meant that you can set the height of the barcode in config and all barcodes will be that height. This is and has been working because picquer/php-barcode-generator allows height to be entered. I just meant fixed as in 'set and it doesn't vary like the width.

@objecttothis
Copy link
Member Author

I pushed a commit that works if picquer will add preserveAspectRatio="none" as an attribute to their <svg> tag. I have a request out to them to consider it so we will see what they say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants