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

Cut after last label only #150

Open
stuartlynne opened this issue Mar 2, 2024 · 8 comments
Open

Cut after last label only #150

stuartlynne opened this issue Mar 2, 2024 · 8 comments

Comments

@stuartlynne
Copy link

My application prints either one or two labels on pre-cut 62x100 labels.

I need to cut after the last label only.

If a single label is printed cut after it.

If two labels are printed cut only after the second.

I am using pdf2image convert_from_bytes to generate an images list (from pdf on stdin.)

And then:

model = 'QL-710W'
printer = 'tcp://192.168.40.16:9100'
kwargs = { 'rotate': '90', 'cut': False, 'label': labelsize,
qlr = BrotherQLRaster(model)
instructions = convert(qlr, images, **kwargs)
send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

Setting cut to False I get no cut. Setting it to True I get a cut after each label.

Suggestions? Thanks!

@FriedrichFroebel
Copy link

This does not seem to be supported without further changes as both command sets handled here are supported by your model:

try:
if cut:
qlr.add_autocut(True)
qlr.add_cut_every(1)
except BrotherQLUnsupportedCmd:
pass
try:
qlr.dpi_600 = dpi_600
qlr.cut_at_end = cut
qlr.two_color_printing = True if red else False
qlr.add_expanded_mode()
except BrotherQLUnsupportedCmd:
pass
You might try to use

convert(qlr, images, **kwargs)
qlr.cut_at_end = True
qlr.add_expanded_mode()
instructions = qlr.data

but I have not tested it and this probably will not actually work.

@stuartlynne
Copy link
Author

stuartlynne commented Mar 2, 2024 via email

@FriedrichFroebel
Copy link

FriedrichFroebel commented Mar 3, 2024

Then you might want to create your custom raster class:

class CutAtEndRaster(BrotherQLRaster):
    def add_expanded_mode(self):
        self.cut_at_end = True
        return super().add_expanded_mode()


qlr = CutAtEndRaster(model)
instructions = convert(qlr, images, **kwargs)
send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

@stuartlynne
Copy link
Author

stuartlynne commented Mar 3, 2024 via email

@FriedrichFroebel
Copy link

FriedrichFroebel commented Mar 3, 2024

Did you set cut=False for this? Then you are only left with doing the same as in my previous comment with add_cut_every(n) and setting n to the number of pages you have while enabling cut=True as far as I understand.

@stuartlynne
Copy link
Author

stuartlynne commented Mar 3, 2024 via email

@FriedrichFroebel
Copy link

FriedrichFroebel commented Mar 4, 2024

convert(qlr, images, **kwargs)
qlr.add_cut_every(2)

is wrong. You need a custom BrotherQLRaster class which overrides add_cut_every with your custom logic and cut=True set, as convert does not allow you to pass these parameters directly.

@stuartlynne
Copy link
Author

stuartlynne commented Mar 5, 2024 via email

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

No branches or pull requests

2 participants