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
Copy link

The backport to version-15 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-version-15 version-15
# Navigate to the new working tree
cd .worktrees/backport-version-15
# Create a new branch
git switch --create backport-136-to-version-15
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3d692fc822310735eb62b52d0779a9cb9ba97808
# Push it to GitHub
git push --set-upstream origin backport-136-to-version-15
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-version-15

Then, create a pull request where the base branch is version-15 and the compare/head branch is backport-136-to-version-15.

@agritheory agritheory restored the zpl_utils branch February 12, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants