brother_ql icon indicating copy to clipboard operation
brother_ql copied to clipboard

Cut after last label only

Open stuartlynne opened this issue 11 months ago • 8 comments

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!

stuartlynne avatar Mar 02 '24 09:03 stuartlynne

This does not seem to be supported without further changes as both command sets handled here are supported by your model: https://github.com/pklaus/brother_ql/blob/56cf4394ad750346c6b664821ccd7489ec140dae/brother_ql/conversion.py#L175-L187 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.

FriedrichFroebel avatar Mar 02 '24 09:03 FriedrichFroebel

No, that did not work.

On Sat, Mar 2, 2024 at 1:27 AM FriedrichFroebel @.***> wrote:

This does not seem to be supported without further changes as both command sets handled here are supported by your model: https://github.com/pklaus/brother_ql/blob/56cf4394ad750346c6b664821ccd7489ec140dae/brother_ql/conversion.py#L175-L187 You might try to use

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

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

— Reply to this email directly, view it on GitHub https://github.com/pklaus/brother_ql/issues/150#issuecomment-1974744742, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWJS7Y27TKQ5TFHXCE3YWGLONAVCNFSM6AAAAABEC6AQA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUG42DINZUGI . You are receiving this because you authored the thread.Message ID: @.***>

-- O_ -<,_____ ()/(_)______


@.***>____604-518-1749(m)__604-461-7532(h)

stuartlynne avatar Mar 02 '24 19:03 stuartlynne

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)

FriedrichFroebel avatar Mar 03 '24 17:03 FriedrichFroebel

That gets a cut after each label.

On Sun, Mar 3, 2024 at 9:56 AM FriedrichFroebel @.***> wrote:

Then you might want to create your custom raster class:

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

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

— Reply to this email directly, view it on GitHub https://github.com/pklaus/brother_ql/issues/150#issuecomment-1975244987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWLRIGSQYF7AJ6UW5ZTYWNP55AVCNFSM6AAAAABEC6AQA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGI2DIOJYG4 . You are receiving this because you authored the thread.Message ID: @.***>

-- O_ -<,_____ ()/(_)______


@.***>____604-518-1749(m)__604-461-7532(h)

stuartlynne avatar Mar 03 '24 18:03 stuartlynne

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.

FriedrichFroebel avatar Mar 03 '24 19:03 FriedrichFroebel

This is cuts every label if 'cut' is True, or no cuts if False

┆ kwargs = { 'rotate': '90', 'cut': True, 'label': labelsize, } ┆ qlr = BrotherQLRaster(model) ┆ convert(qlr, images, **kwargs) ┆ qlr.add_cut_every(2) ┆ instructions = qlr.data ┆ send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

This was the previous. Again with 'cut' False no cuts, 'cut' True cuts after each label.

┆ kwargs = { 'rotate': '90', 'cut': False, 'label': labelsize, } ┆ class CutAtEndRaster(BrotherQLRaster): ┆ def add_expanded_mode(self): ┆ self.cut_at_end = True ┆ super().add_expanded_mode() ┆ qlr = CutAtEndRaster(model) ┆ convert(qlr, images, **kwargs) ┆ qlr.add_expanded_mode() ┆ instructions = qlr.data ┆ send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

On Sun, Mar 3, 2024 at 11:57 AM FriedrichFroebel @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/pklaus/brother_ql/issues/150#issuecomment-1975279403, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWPTZY234ARZAY5EGW3YWN6CNAVCNFSM6AAAAABEC6AQA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGI3TSNBQGM . You are receiving this because you authored the thread.Message ID: @.***>

-- O_ -<,_____ ()/(_)______


@.***>____604-518-1749(m)__604-461-7532(h)

stuartlynne avatar Mar 03 '24 20:03 stuartlynne

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.

FriedrichFroebel avatar Mar 04 '24 11:03 FriedrichFroebel

I thought something like this would work, but still get cuts after every label:

┆ kwargs = { 'rotate': '90', 'cut': False, 'label': labelsize, } ┆ class CutAtEndRaster(BrotherQLRaster): ┆ def init(self, model, pages): ┆ self.pages = pages ┆ self.page_count = 0 ┆ print('pages: %s' % (pages), file=sys.stderr) ┆ super(CutAtEndRaster, self).init(model) ┆

┆ def add_autocut(self, flag):

┆ self.page_count += 1 ┆ print('add_autocut: flag: %s page_count: %s' % (flag, self.page_count), file=sys.stderr) ┆ if self.page_count == self.pages: ┆ print('add_autocut: calling super', file=sys.stderr)

┆ super(CutAtEndRaster, self).add_autocut(flag)

┆ ┆ def add_cut_every(self, n): ┆ print('add_cut_every: n: %s overide: %s' % (n, self.pages), file=sys.stderr) ┆ if self.page_count == self.pages:

┆ print('add_autocut: calling super', file=sys.stderr)

┆ super(CutAtEndRaster, self).add_cut_every(self.pages) ┆ ┆ qlr = CutAtEndRaster(model, len(images)) ┆ convert(qlr, images, **kwargs) ┆ instructions = qlr.data ┆ send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

On Mon, Mar 4, 2024 at 3:15 AM FriedrichFroebel @.***> wrote:

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 misses these parameters.

— Reply to this email directly, view it on GitHub https://github.com/pklaus/brother_ql/issues/150#issuecomment-1976347030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWJ4C5A24XUS77GR6QTYWRJV3AVCNFSM6AAAAABEC6AQA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZWGM2DOMBTGA . You are receiving this because you authored the thread.Message ID: @.***>

-- O_ -<,_____ ()/(_)______


@.***>____604-518-1749(m)__604-461-7532(h)

stuartlynne avatar Mar 05 '24 00:03 stuartlynne