GithubHelp home page GithubHelp logo

pklaus / brother_ql_web Goto Github PK

View Code? Open in Web Editor NEW
252.0 252.0 124.0 372 KB

A Python-based web service to print labels on Brother QL label printers. Based on brother_ql: https://github.com/pklaus/brother_ql

License: GNU General Public License v3.0

Python 52.35% CSS 0.79% HTML 46.86%
brother-ql label-printing ql-500 ql-700 ql-710w web-ui

brother_ql_web's Introduction

pklaus

Mono-repo with collected Python works.

brother_ql_web's People

Contributors

christopherhackett avatar jeroen684 avatar mikafinja avatar pklaus avatar reinierh avatar robinsloan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brother_ql_web's Issues

QL-800 red blinking light on print

I didn't change anything in my environment, although I did a general update after I got this error. Ubuntu 20.04.6 LTS, can't work it out. Was working for a year prior to this. (Great app, thank you saves a lot of time).

invalid literal for int() with base 16: 'Brother' on Mac OS X

I'm trying to use this app with a Brother QL-700 connected through an ethernet Silex USB server. This might be the problem, but maybe not. Other OS X apps can communicate with the QL-700 fine, and System Profiler shows the address of the QL-700 to be "usb://Brother/QL-700?serial=000F2Z67XXXX" (replaced numbers with Xs), which I entered in the configuration file. However, when I try to print, I get:

invalid literal for int() with base 16: 'Brother'

which I assume is the "Brother" in the USB device address. The problem appears to be in the pyusb backend in the brother_ql project. It's expecting a USB vendor and product ID, and not a name that can occur in OS X. However, I might be out of luck, because when I list all devices using pyusb, the Brother doesn't appear there.

Any suggestions? Perhaps I will need to make another backend for this pseudo USB connection.

How to detect if device is connected?

I found that the code will throw "Device not found" error when the device isn't connected. But this error is only at the runtime. Can we detect the device connection without triggering print job?

Printing a predertermined layout via api

Hello.

we want to print some file identification labels that must contain a filename and a barcode for the file . is there anyway to create a layout with the placeholders and send the api the information via variables lets say print.php?filename=this file&barcode=5486568

thanks!
AR

CLI parameter to omit using any system-wide fonts

Something along the lines of PR #21
would be nice! There, the user has to actively specify --system-fonts to use them. I think the default should be: use the system fonts. So the CLI parameter should rather be: --omit-system-fonts or similar.

Default orientation is not selected

When opening the webinterface, no option box of the orientation is selected.
I think in brother_ql_web.py in line 303 something like this is missing:
'default_orientation': CONFIG['LABEL']['DEFAULT_ORIENTATION']}

Autodetect the loaded label type

There's a command to let the printer return the currently loaded label type. It would make sense to use that to only display label options that are currently possible.

No handlers could be found for logger "brother_ql.devicedependent"

Got a new Raspberry Pi Zero, loaded the latest OS, loaded brother_ql_web and get this message:
No handlers could be found for logger "brother_ql.devicedependent"
Traceback (most recent call last):
File "./brother_ql_web.py", line 28, in
except FileNotFoundError as e:
NameError: name 'FileNotFoundError' is not defined

Any suggestions?

number of labels / Cut button?

Hi guys,

Not sure if I should ask this in "issues" but found nowhere else to ask for this.

I'd like to request 2 features that I "think" shouldn't be too hard to implement:

1 - A numerical input to set a number of labels to print (defaults to 1).
2- A cutter enabled/disabled checkbox so that the labels aren't cut after every print and a "cut" button that runs the cutter.

This would allow us to print multiple copies of the same labels while disabling the cutter and manually cut at the end.

Thanks

How to print in grayscale

Is there a way to print labels with the gray scale values intact, or does brother_ql only support black and white thresholding? My label printer will print fine in grayscale when other software is used, but then there is the usual issue of paper size.

Print Job returns success but the printer does not print the label

Hi,

I am testing out this library with my label printer (Model: QL-820NWB) which is connected over Wifi. The library is able to detect the printer but when I try to send an image file with dimensions 696x1109, the job succeeds with message DEBUG:brother_ql.raster:raster_image_size: 720x1109. However, the printer throws an error Check the print data and try again. My current label size, inside my printer, is 62mm. I am able to print a 62mmx100mm image from P-touch editor.

Could you please let me know if there is something which I am missing here?

Deprecation Warning from Pillow

The used library Pillow seems to change and it might be necessary to react?

brother_ql_web.py:120: DeprecationWarning: multiline_textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use multiline_textbbox instead.
textsize = draw.multiline_textsize(text, font=im_font)

How to run on windows?

I am trying to run this on windows and getting error on font_helpers.py file method get_fonts(). Seems like fc-scan is working only on Linux?

Fonts

  • OS: Mac Sierra
  • Language: Python 3

I can't start the web server with no parameters, per the instructions. I also cannot start the server when I supply a font-folder parameter. Same error.

deprecation warning: brother_ql.devicedependent is deprecated and will be removed in a future release
Traceback (most recent call last):
  File "./brother_ql_web.py", line 296, in <module>
    main()
  File "./brother_ql_web.py", line 271, in main
    FONTS = get_fonts()
  File "/Users/justindm/Development/printer/brother_ql_web/font_helpers.py", line 25, in get_fonts
    styles = parts[2].split('=')[1].split(',')
IndexError: list index out of range

I manually run fc-scan --format "%{file}:%{family}:style=%{style}\n" /my/directory/Fonts and get about 40 lines.

Printing failure on Raspberry Pi/QL-700 (blinking red LED)

So I finally got a chance to upgrade to the latest versions of brother_ql and brother_ql_web, and now am encountering new errors. For reference I'm using a Brother QL-700 on a Raspberry Pi (Raspbian Stretch, kernel ver 4.14.50-v7+) with Python 3.5.3 and pip 18.1.

If I attempt to run it as a non-root user (e.g. pi user), I get "permission denied" errors on /dev/usb/lp0 (I've confirmed this is the correct device for my printer) when attempting to print.

If I attempt to run it as root, the web app says "printing successful", but the console spits out this error

WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.
WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.

and nothing prints; the LED on the printer blinks red @ 0.5Hz. The full output running loglevel DEBUG is as follows:

Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://:8013/
Hit Ctrl-C to quit.

/usr/local/lib/python3.5/dist-packages/bottle.py:3335: DeprecationWarning: Absolute template path names are deprecated.
  fname = self.search(name, self.lookup)
192.168.1.162 - - [10/Oct/2018 14:27:15] "GET /labeldesigner HTTP/1.1" 200 12519
192.168.1.162 - - [10/Oct/2018 14:27:15] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 0
192.168.1.162 - - [10/Oct/2018 14:27:15] "GET /static/css/custom.css HTTP/1.1" 304 0
192.168.1.162 - - [10/Oct/2018 14:27:15] "GET /static/js/jquery.min.js HTTP/1.1" 304 0
192.168.1.162 - - [10/Oct/2018 14:27:15] "GET /static/js/bootstrap.min.js HTTP/1.1" 304 0
192.168.1.162 - - [10/Oct/2018 14:27:15] "POST /api/preview/text?return_format=base64 HTTP/1.1" 200 4320
WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.
WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.
DEBUG:brother_ql.raster:raster_image_size: 720x90
192.168.1.162 - - [10/Oct/2018 14:27:18] "POST /api/print/text HTTP/1.1" 200 41856

Here is some information from my system about the printer:

$ lpstat -s
no system default destination
members of class LabelPrinter:
	QL-700
device for LabelPrinter: ///dev/null
device for QL-700: usb://Brother/QL-700?serial=000B5Z809299
$ ls -lZ /dev/usb
total 0
crw-rw---- 1 root lp ? 180, 0 Oct  9 17:17 lp0

Font Alignment via API

Is there a way to do the Font Alignment via the API aswell?

I tried:
"font_alignment" => "left",

But that wasn't working.

Error on trying to run ./brother_ql_web

When i try to run the script after installing the package i get the following error:
Traceback (most recent call last): File "./brother_ql_web.py", line 12, in <module> from PIL import Image, ImageDraw, ImageFont ImportError: No module named PIL
any hint how to fix is I highly appreciated!

Add leading

It would be nice to get some leading between the lines. I used the following to get a line-height of 150%:

textsize = draw.multiline_textsize(text, font=im_font, spacing=kwargs['font_size']//2)

draw.multiline_text(offset, text, (0), font=im_font, align=kwargs['align'], spacing=kwargs['font_size']//2)

no empty lines

Labels can not contain empty lines. If there is a completely empty line on the label, the server returns a 500 error. If the empty line contains a space character (or any other character), the label is generated correctly.

Fails:

X

Y

Works:

X
 
Y

Add configuration file

Add a configuration file to store a persitant configuration of the application. Currently some features are only "configurable" by editing the source code. These edits will be overwritten by an update of the app. This issue can be fixed by adding support for a configuration file and providing an example configuration file which will be used as a fall back, if no local configuration is avaliable.

Print on SMB shared printer

I am very keen on this project and I managed to get it work on an raspberry pi. But now I have the need to move to an other machine. From there my Labelprinter is available via smb share. I know I can use file:///dev/usb/lp0 or tcp://192.168.0.23:9100 to tell this interface which printer to use, but the smb://.... is not working. There is a message saying backend not available.

Is there a way to use this with an smb shared printer ?

Thanks for your help.

QL-820NWB @62mm endless does not work

tested the following container

docker run \
  --name brother_ql_web \
  --detach \
  --publish 8013:8013 \
  --restart=always \
  pklaus/brother_ql_web:latest \
  ./brother_ql_web.py --model QL-820NWB tcp://192.168.0.57

endless does not appear to work, printer led flashes orange, but 62mm red is working lol

Uploading ready-to-print graphics

Hey Philipp,

thanks a lot for sharing your code, great work!
My main use case is printing post stamps from Deutsche Post online service "internetmarke". Stamps are delivered as a PDF file. Customers are able to choose the Brother DK-22205, so the PDF is generated in an appropriate size. Here you find a Sample File.

Do you think it would be much effort to add an upload function for such files to the web ui?
While writing this I realize that brother_ql might just accept .png files for now, which would be another problem to solve...
However, maybe we can start with an upload function for .png files?

Reflect font-selection in frontend

Not sure how this was supposed to work, but I needed the following in views/labeldesigner.jinja2" line 54:
<option {% if label['DEFAULT_FONTS']['style'] == font_style and label['DEFAULT_FONTS']['family'] == font_family_name %}selected{% endif %}>{{font_family_name}} ({{ font_style }})</option>

Workaround for AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

The current version doesn't work. I'm no python expert at all, but downgrading Pillow worked for me as a workaround:

pip3 install Pillow==9.5.0

This is the error backtrace:

127.0.0.1 - - [14/Jan/2024 12:45:50] "POST /api/preview/text?return_format=base64 HTTP/1.1" 500 778
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 876, in _handle
    return route.call(**args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 1759, in wrapper
    rv = callback(*a, **ka)
         ^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 192, in print_text
    im = create_label_im(**context)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 119, in create_label_im
    linesize = im_font.getsize(text)
               ^^^^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
127.0.0.1 - - [14/Jan/2024 12:45:51] "POST /api/print/text HTTP/1.1" 500 755
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 876, in _handle
    return route.call(**args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 1759, in wrapper
    rv = callback(*a, **ka)
         ^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 152, in get_preview_image
    im = create_label_im(**context)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 119, in create_label_im
    linesize = im_font.getsize(text)
               ^^^^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

Log printed labels to stdout

See ba35a10 and 5d079b8
Those are commits from @Jeroen684 from PR #16. They also silence bottle's web server log on stdout.

I put this here for me as a reminder while merge-closing the PR otherwise (merging only the commit about the file encoding the PR was about originally).

Flashing LED on QL-500

I'm trying to use this interface to create a label on my Brother QL-500 but all that happens is that the green LED is flashing.

Here's what happens when I use the label designer:

127.0.0.1 - - [16/Dec/2016 17:46:13] "GET /api/preview/text/test?font_family=Arial&font_size=70 HTTP/1.1" 200 1734
WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.
WARNING:brother_ql.raster:Trying to switch the operating mode on a printer that doesn't support the command.
WARNING:brother_ql.raster:Trying to call add_autocut with a printer that doesn't support it
WARNING:brother_ql.raster:Trying to call add_cut_every with a printer that doesn't support it
WARNING:brother_ql.raster:Trying to set expanded mode (dpi/cutting at end) on a printer that doesn't support it
WARNING:brother_ql.raster:Trying to set compression on a printer that doesn't support it
INFO:brother_ql.raster:raster_image_size: 720x90
127.0.0.1 - - [16/Dec/2016 17:46:18] "GET /api/print/text/test?font_family=Arial&font_size=70 HTTP/1.1" 200 42172

The server was started with:

./brother_ql_web.py --model QL-500 --loglevel DEBUG file:///dev/lp/printers/usb-Brother_QL-500_F4Z731433

Anything I can do to help debugging this?

move static folder inside of labeldesigner

I am running the label printer behind a reverse proxy to clean up the port for my wife. I am redirecting local.domain/labelprinter to docker.host:8013/labeldesigner which breaks because the /static folder is not reachable.

Easiest fix would be to have the static folder in the same level as /labeldesigner?

IDEA: serialized qr code for asn workflow

Hi,
on https://github.com/tmaier/asn-qr-code-label-generator there is a great tool to print ASN's on A4 paper. Besides that it is a challenge to get the prints neatly placed on the labels it appears obvious to use the QL printer for this use case.
The p-touch software allows for all I admit but I need to start windows for this (see page 96 or so in the QL-820mwb manual); for printing stand alone an extra handheld scanner is needed and the overall setup doesn't appear to be convenient.
However, it would be great to get away from p-touch and Windows and have a OS-agnostic solution.
Would this be an interesting use case to take on?
Cheers, Hans

NotImplementedError when attempting to print

I have been able to successfully print PNG images using the brother_ql CLI; however, when attempting to print using brother_ql_web, I see the following error on the webserver:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/bottle.py", line 862, in _handle
    return route.call(**args)
  File "/usr/local/lib/python3.7/site-packages/bottle.py", line 1740, in wrapper
    rv = callback(*a, **ka)
  File "./brother_ql_web.py", line 198, in print_text
    create_label(qlr, im, context['label_size'], threshold=context['threshold'], cut=True, rotate=rotate)
  File "/usr/local/lib/python3.7/site-packages/brother_ql/brother_ql_create.py", line 54, in create_label
    convert(qlr, [image], label_size, threshold=threshold, cut=cut, dither=dither, compress=compress, red=red, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/brother_ql/conversion.py", line 89, in convert
    raise NotImplementedError("The image argument needs to be an Image() instance or the filename to an image.")
NotImplementedError: The image argument needs to be an Image() instance or the filename to an image.

The web interface unhelpfully reports

Printing was unsuccessful:
undefined

I was initially running Python 3.7.0 (manually built/installed) in Raspbian 8.0, on a Raspberry Pi 3 model B. Since the sole purpose of this Pi is to be a print server, I re-flashed it with the more recent Raspbian 9.0, and tried running with the stock Python 3.5.3, but still get the exact same error.

If you need any further information please let me know.

RED FLASHING LED on QL-800

Whenever I try to print at the correct format (29mm endless) the LED starts flashing red and nothing happens while the web-interface says "Printing was successful".

sudo ./brother_ql_web.py --loglevel DEBUG
...
Bottle v0.12.16 server starting up (using WSGIRefServer())...
Listening on http://:8013/
Hit Ctrl-C to quit.

127.0.0.1 - - [10/May/2019 21:53:38] "POST /api/preview/text?return_format=base64 HTTP/1.1" 200 404
127.0.0.1 - - [10/May/2019 21:53:39] "POST /api/preview/text?return_format=base64 HTTP/1.1" 200 632
127.0.0.1 - - [10/May/2019 21:53:40] "POST /api/preview/text?return_format=base64 HTTP/1.1" 200 632
DEBUG:brother_ql.raster:raster_image_size: 720x107
DEBUG:brother_ql.backends.generic:Writing 10195 bytes.
127.0.0.1 - - [10/May/2019 21:53:41] "POST /api/print/text HTTP/1.1" 200 17

My config.json:

{
  "SERVER": {
    "PORT": 8013,
    "HOST": "",
    "LOGLEVEL": "WARNING",
    "ADDITIONAL_FONT_FOLDER": false
  },
  "PRINTER": {
    "MODEL": "QL-800",
    "PRINTER": "usb://04f9:209b/000H8Z203810"
  },
  "LABEL": {
    "DEFAULT_SIZE": "29",
    "DEFAULT_ORIENTATION": "standard",
    "DEFAULT_FONT_SIZE": 5,
    "DEFAULT_FONTS": [
      {"family": "Minion Pro",      "style": "Semibold"},
      {"family": "Linux Libertine", "style": "Regular"},
      {"family": "DejaVu Serif",    "style": "Book"}
    ]
  },
  "WEBSITE": {
    "HTML_TITLE": "Label Designer",
    "PAGE_TITLE": "Brother QL Label Designer",
    "PAGE_HEADLINE": "Design your label and print it…"
  }
}

I'm thankful for every help!

brother_ql.devicedependent is deprecated

I tried running the brother_ql_web.py file and I got the following error:

deprecation warning: brother_ql.devicedependent is deprecated and will be removed in a future release

label don't gets cutted after printing

I have to cut the Label manually on the Printer after printing. Over the Brother Driver (like "$ brother_ql_print DS_Logo.bin /dev/usb/lp0") the Label gets cutted immediately. I would appreciate a function (maybe in the "config.json" or directly in the fronted) to tell if the label gets cutted or not.

icon font is missing

The used icon font is not included in the repository. The calls to the font files all result in 404 errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.