Class: ZplRenderer::Sanitizer
- Inherits:
-
Object
- Object
- ZplRenderer::Sanitizer
- Defined in:
- lib/zpl_renderer/sanitizer.rb
Overview
Normalizes carrier ZPL quirks before validation/render.
Two repairs are applied:
-
Invalid field origins such as
^FO464,--^GB2,126,2^FSfrom carrier ZPL. Invalid numeric params become 0 on printers; for a vertical rule we reuse the last horizontal section-divider Y so the divider lands in the middle band instead of y=0. -
Print widths narrower than the requested canvas. The engine draws on a +^PW+-wide canvas and centers it, so fields near the right edge (some templates put rotated text at
^FO791under^PW800) are clipped. Widening^PWto the canvas and shifting^LHby the same centering offset keeps every field in its original position while leaving nothing cut off.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- COMMAND =
/\^(FO|FT)([^,\^]*),([^,\^]*)/i- PRINT_WIDTH =
/\^PW(\d+)/i- LABEL_HOME =
/\^LH(\d+),(\d+)/i- INVERTED_ORIENTATION =
/\^POI/i
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(zpl, canvas_dots: nil) ⇒ Sanitizer
constructor
A new instance of Sanitizer.
Constructor Details
#initialize(zpl, canvas_dots: nil) ⇒ Sanitizer
Returns a new instance of Sanitizer.
26 27 28 29 30 |
# File 'lib/zpl_renderer/sanitizer.rb', line 26 def initialize(zpl, canvas_dots: nil) @zpl = zpl.to_s @canvas_dots = canvas_dots @repairs = [] end |
Class Method Details
.sanitize(zpl, canvas_dots: nil) ⇒ Object
38 39 40 |
# File 'lib/zpl_renderer/sanitizer.rb', line 38 def self.sanitize(zpl, canvas_dots: nil) new(zpl, canvas_dots: canvas_dots).call end |