inventree / inventree-brother-plugin

Label printing plugin for Brother series printers
MIT License
16 stars 12 forks source link

Define label size #14

Closed gunstr closed 1 year ago

gunstr commented 1 year ago

I would need a bit of guidance...

I have installed the plugin but I can't figure out how or where to define the size of the labels in a way that is accepted byt the brother_ql library why I'm a bit stuck.

I have tried to change the size from the stock item label settings in the admin page and also tried a fair amount of different label templates with no success. Whatever I do I get an error stating the size is wrong.

The printer I use is QL-700 and the actual label size is 62x29mm.

I have to admit that I' have limited knowledge in html/css but at least I can see changes in reported size in the error message and have come so close as one single pixel from the expected height/width value as you can see below. I can reach this by setting the label size to 59x23mm either in the admin panel or by changing the page size section in the label template to 59x23mm. But I see no changes when I set the values with decimals to 58.928x22.9447mm, it seems the decimals are taken away somewhere. I have also tried using margin settings in the template, but it seems to have no impact.

I see you have a TODO in the code to fix padding and auto scaling, but is there no way to fix this by using label settings or a correct template?

Traceback (most recent call last):

File "/home/inventree/src/InvenTree/plugin/base/label/label.py", line 47, in print_label
plugin.print_label(

File "/home/inventree/env/lib/python3.8/site-packages/inventree_brother/brother_plugin.py", line 141, in print_label
instructions = convert(**params)

File "/home/inventree/env/lib/python3.8/site-packages/brother_ql/conversion.py", line 126, in convert
raise ValueError("Bad image dimensions: %s. Expecting: %s." % (im.size, dots_expected))

ValueError: Bad image dimensions: (697, 272). Expecting: (696, 271).
matmair commented 1 year ago

@SchrodingersGat any insights? I am not really sure if there is anything special required to set the label size.

SchrodingersGat commented 1 year ago

@gunstr this feels like it might be on the brother_ql end, maybe related to DPI? We might be able to work around it, but probably going to need some more information. I don't have access to that printer, if you can do some digging and testing on your end, might be the quickest path to working it out. Would you like some pointers into the label printing plugin framework?

gunstr commented 1 year ago

I finally got a bit further and by setting the label size to 58.928x22.944 in the "stock item label" admin page the brother_ql library does not generate an error - not sure why I could not get decimals to work yesterday...

I still do not get any labels printed though but that is clearly on the brother_ql end or something related to CUPS configuration. From the brother_ql CLI I can print using the linux_kernel, but with network as backend it just reports the data has been sent but nothing is being printed.

Closing this issue as the plug-in seems to work as it should.