Skip to main content

SBPL module for remote printing

Project description

SBPL

SBPL module for remote printing

Summary

This provides the function of remote printing directly to the printer existing on your LAN by using SBPL (SATO Barcode Printer Language) provided by SATO Corp.

This enables arbitrary label cutting which can not be controlled by a normal Windows printer.

This module has a function to print TrueType fonts using Freetype. Execute method ttf_write().

This module is a prototype and may not satisfy your work, but since it is Pure Python, you can add and change features yourself.

Install

$ pip install sbpl

Usage

from sbpl import *

comm = SG412R_Status5()
with comm.open("192.168.0.251", 1024):
    comm.prepare()

    # generate label...
    gen = LabelGenerator()
    with gen.packet_for_with():
        with gen.page_for_with():
            gen.set_label_size((1000, 3000))
            gen.rotate_270()
            gen.pos((260, 930))
            gen.codebar(("0004693003005000", 3, 100))
            gen.pos((160, 1000))
            gen.expansion((1,1))
            gen.bold_text("0004693003005000")
            gen.print()
    
    comm.send(gen.to_bytes())
    comm.finish()

You can describe print contents in JSON format and can specify them all together.

JSON:

[
    {"host":"192.168.0.251", "port": 1024, "communication": "SG412R_Status5"},
    [
        {"set_label_size": [1000, 3000]},
        {"shift_jis": 0},
        {"rotate_270": 0},
        {"comment":"==ticket main=="},
        {"pos": [710, 130], "expansion": [6000], "ttf_write": "TEST CONSERT", "font": "mplus-1p-medium.ttf"},
        {"pos": [530, 1040], "expansion": [2700], "ttf_write": "Organizer: Python High School", "font": "mplus-1p-medium.ttf"},
        {"pos": [370, 50], "expansion": [3700], "ttf_write": "Friday, February 14, 2014 14:00", "font": "mplus-1p-medium.ttf"},
        {"pos": [300, 80], "expansion": [2800], "ttf_write": "Indoor playground", "font": "mplus-1p-medium.ttf"},
        {"pos": [230, 30], "expansion": [3500], "ttf_write": "Free seat $5.00", "font": "mplus-1p-medium.ttf"},
        {"pos": [180, 50], "expansion": [1800], "ttf_write": "Drinks can be brought in but alcohol is prohibited.", "font": "mplus-1p-medium.ttf"},
        {"comment":"==barcode=="},
        {"pos": [260, 930], "codebar": ["0004693003005000", 3, 100]},
        {"pos": [160, 1000], "expansion": [1,1], "bold_text": "0004693003005000"},
        {"comment":"==ticket parted=="},
        {"pos": [780, 1610], "expansion": [2500], "ttf_write": "TEST", "font": "mplus-1p-medium.ttf"},
        {"pos": [670, 1610], "expansion": [2500], "ttf_write": "CONSERT", "font": "mplus-1p-medium.ttf"},
        {"pos": [620, 1630], "expansion": [2000], "ttf_write": "Friday, February 14, 2014 14:00", "font": "mplus-1p-medium.ttf"},
        {"pos": [580, 1630], "expansion": [2000], "ttf_write": "14:00", "font": "mplus-1p-medium.ttf"},
        {"pos": [420, 1610], "expansion": [2000], "ttf_write": "Free seat", "font": "mplus-1p-medium.ttf"},
        {"pos": [330, 1600], "expansion": [2000], "ttf_write": "$5.00", "font": "mplus-1p-medium.ttf"},
        {"print": 1}
    ]
]

Python:

from sbpl import *

json_str = "(defined adobe)"
comm = SG412R_Status5()
gen = LabelGenerator()
parser = JsonParser(gen)
parser.parse(json_str)
parser.post(comm)

License

MIT

Author

Copyright 2018 KATO Kanryu(k.kanryu@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbpl-0.1.2.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file sbpl-0.1.2.tar.gz.

File metadata

  • Download URL: sbpl-0.1.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for sbpl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 49e6b1c1c0c64de1b0d3ba1652b3487923c86f305463b26182ac03271fb7a7f5
MD5 f626013e143f4651ae84baa1e8e733d6
BLAKE2b-256 29b98bbf7d80855b5948bce640e3a352c13fdca013015b583ca9e54a415a3c45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page