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

ZPL Utils #136

Merged
merged 6 commits into from
Jul 17, 2024
Merged

ZPL Utils #136

merged 6 commits into from
Jul 17, 2024

Conversation

agritheory
Copy link
Owner

@agritheory agritheory commented Jul 1, 2024

This PR provides a couple of ZPL related utilities and POC for BEAM.

A print preview using a jinja method and the free Labelary API

image

A POC for click-to-print

This utilizes a CUPS instance that is on the same network or localhost to the ERPNext instance. Authentication if required would be a stretch goal.

image

A ZPL and jinja mixed environment

This allows the use of the helpers from the py-zebra-zpl library for object-orient label composition.

image

{% set hu = get_handling_unit(doc.name) %}
{% set label = zebra_zpl_label(width=6*203, length=4*203, dpi=203, orientation="R") -%}

{{ label.add(zebra_zpl_barcode(hu.handling_unit, width=4, height=260, position=(120, 40), justification="C", ratio=1, human_readable='N', orientation="N")) -}}
{{ label.add(zebra_zpl_text(hu.handling_unit, position=(40, 320), width=(4*203-80), font_size=40, justification="R", orientation="N")) }}
{{ label.add(zebra_zpl_text(frappe.utils.cstr(hu.qty) + " " + hu.uom, position=(120, 400), width=(4*203-80), font_size=40, orientation="N")) }}
{{ label.add(zebra_zpl_text(hu.item_code, position=(120, 480), width=(4*203-80), font_size=40, orientation="N")) }}
{{ label.add(zebra_zpl_text(hu.warehouse, position=(120, 560), width=(4*203-80), font_size=40, orientation="N")) }}
{{ label.add(zebra_zpl_text(frappe.utils.format_datetime(hu.posting_datetime), position=(120, 640), width=(4*203-80), font_size=40, orientation="N")) }}

{{ label.dump_contents() }}
It almost works, I am having an issue getting the orientation correct.

image

labelary print preview (to image)
py-zebra-zpl wrappers to jinja methods (text and OOP interfaces)
@agritheory agritheory requested a review from Alchez July 1, 2024 23:47
@Alchez
Copy link
Collaborator

Alchez commented Jul 2, 2024

@agritheory

  • I couldn't find the dependency on PyPI, so I've added it as a Github URL in pyproject.toml.
  • As for the incorrect orientation, I think the ZPL part of the code is correct and the issue might be coming from printing the generated PNG? Is there a printer-specific orientation setting as well?

@agritheory agritheory merged commit 3d692fc into version-14 Jul 17, 2024
6 checks passed
@Alchez Alchez deleted the zpl_utils branch August 14, 2024 05:33
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

Successfully merging this pull request may close these issues.

3 participants