[cups] Auto-reformatting shipping labels for a 4x6 thermal printer

Alex Korobkin korobkin+cups at gmail.com
Mon Jun 19 12:38:26 PDT 2023


If you really want to deep-dive into this, one way to handle it is to write
your own filter.
Basically, you either register a mime-type conversion
"application/vnd.cups-nick", and tell your CUPS to convert any incoming job
into this type, or,you can modify your printer PPD file to include your
filter, whichever you prefer.
Once the filter receives the incoming job, you can do whatever you want
with it: convert, resize, cut, etc. You'd need to do some scripting or
coding for that, of course.

Check these links for a good explanation of how filters work:
https://en.opensuse.org/SDB:CUPS_in_a_Nutshell#The_Filter_(includes_the_Driver)
https://en.opensuse.org/SDB:Using_Your_Own_Filters_to_Print_with_CUPS

On Sun, Jun 18, 2023 at 5:59 PM Nick Bogdanov <nickrbogdanov at gmail.com>
wrote:

> I started doing small-scale e-commerce projects, and found that manually
> feeding US Letter (8.5x11) sticky labels through my old LaserJet 5L was a
> pain.  So I bought a surplus Zebra GK420d thermal label printer, plugged it
> into my network, and loaded it up with a spool of 4x6 shipping labels.  The
> Zebra printer speaks ZPL and works flawlessly with CUPS.  I have been very
> happy with it so far.
>
> This arrangement is fairly painless when an online service (e.g. FedEx)
> provides a PDF with a label specifically formatted for 4x6 label printers.
> It's more of a hassle when they only want to provide PDFs sized for US
> Letter printers, with 2 labels per sheet (or 1 label per half sheet).  If
> you purchase bulk shipping labels from eBay, for instance, there is no
> option to request 4x6 labels; they just send you one giant PDF with 2
> labels per 8.5x11 page.  If you try to print this to the 4x6 Zebra printer,
> the labels get completely mangled; usually it gets cut off right in the
> middle.
>
> The workarounds I found searching online involved manually importing each
> bulk label PDF into Adobe Acrobat and cropping it by hand.  This isn't a
> very scalable solution and there ought to be a way to make the software do
> the heavy lifting for us.
>
> What I'd like to do is have CUPS notice that I'm printing an 8.5x11 sheet
> of labels to a 4x6 form factor printer, and automatically reformat each
> label on the page to fit the 4x6 media.  I would also like to have the
> ability to optionally resize it to fit on smaller 4x3 labels, which are
> more convenient for tiny packages.
>
> What would be a good way to approach this?  I would be comfortable writing
> some code if needed.  I don't know the CUPS architecture at all, though,
> and I'm not sure where to start.
>
> cc: Michael since he seems to be the main contributor
> to filter/rastertolabel.c
> _______________________________________________
> cups mailing list
> cups at cups.org
> https://lists.cups.org/mailman/listinfo/cups
>


-- 
-Alex


More information about the cups mailing list