{"id":18022979,"url":"https://github.com/kanryu/sbpl","last_synced_at":"2025-03-26T23:30:57.064Z","repository":{"id":47629118,"uuid":"162995399","full_name":"kanryu/sbpl","owner":"kanryu","description":"SBPL(SATO Barcode Printer Language) module for remote printing","archived":false,"fork":false,"pushed_at":"2021-09-13T00:43:29.000Z","size":232,"stargazers_count":14,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T17:13:29.219Z","etag":null,"topics":["printing","python-library","sato","sbpl","socket"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanryu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-24T13:52:12.000Z","updated_at":"2025-02-27T07:39:17.000Z","dependencies_parsed_at":"2022-09-06T12:12:55.235Z","dependency_job_id":null,"html_url":"https://github.com/kanryu/sbpl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fsbpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fsbpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fsbpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanryu%2Fsbpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanryu","download_url":"https://codeload.github.com/kanryu/sbpl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245753858,"owners_count":20666823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["printing","python-library","sato","sbpl","socket"],"created_at":"2024-10-30T07:06:32.942Z","updated_at":"2025-03-26T23:30:56.515Z","avatar_url":"https://github.com/kanryu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SBPL\nSBPL module for remote printing\n\n## Summary\nThis provides the function of remote printing directly \nto the printer existing on your LAN by using SBPL \n(SATO Barcode Printer Language) provided by SATO Corp.\n\nThis enables arbitrary label cutting which can not be controlled\nas a normal Windows printer.\n\nThis module has a function to print TrueType fonts using Freetype. Execute method ttf_write().\n\nThis module also has a function to 'Black/White mode' (means monochrome or glayscale) bitmap printing. Execute method print_bmp().\nThis method cannot be used with the CT series.\n\nThis module is a prototype and may not satisfy your work, \nbut since it is Pure Python, you can add and change features yourself.\n\n\n## Install\n\n```shell\n$ pip install sbpl\n```\n\n## Usage\n```Python\nfrom sbpl import *\n\ncomm = SG412R_Status5()\n# open the socket\nwith comm.open(\"192.168.0.251\", 1024):\n    # send the initialize packet\n    comm.prepare()\n\n    # generate label...\n    gen = LabelGenerator()\n    with gen.packet_for_with():\n        with gen.page_for_with():\n            gen.set_label_size((1000, 3000))\n            gen.rotate_270()\n            gen.pos((260, 930))\n            gen.codabar((\"0004693003005000\", 3, 100))\n            gen.pos((160, 1000))\n            gen.expansion((1,1))\n            gen.bold_text(\"0004693003005000\")\n            gen.print()\n\n    # send the main packet for printing\n    comm.send(gen.to_bytes())\n    \n    # send the finalize packet\n    comm.finish()\n    \n    # (auto closed to exit from 'with:')\n```\n\n## Multiple Page Labels\n\nMultiple pages of label data can be com.send() between com.prepare() and com.finish().\nSince LabelGenerator caches label data for multiple pages, com.send() needs only to be called once at the end.\n\nThe label paper will usually be cut page by page, depending on the printer's default settings. If you do not want to cut, call gen.skip_cutting().\n\n## SBPL Json Format\n\nYou can describe print contents in JSON format and can specify them all together.\n\nJSON:\n\n```JSON\n[\n    {\"host\":\"192.168.0.251\", \"port\": 1024, \"communication\": \"SG412R_Status5\"},\n    [\n        {\"set_label_size\": [1000, 3000]},\n        {\"shift_jis\": 0},\n        {\"rotate_270\": 0},\n        {\"comment\":\"==ticket main==\"},\n        {\"pos\": [710, 130], \"expansion\": [6000], \"ttf_write\": \"TEST CONSERT\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [530, 1040], \"expansion\": [2700], \"ttf_write\": \"Organizer: Python High School\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [370, 50], \"expansion\": [3700], \"ttf_write\": \"Friday, February 14, 2014 14:00\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [300, 80], \"expansion\": [2800], \"ttf_write\": \"Indoor playground\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [230, 30], \"expansion\": [3500], \"ttf_write\": \"Free seat $5.00\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [180, 50], \"expansion\": [1800], \"ttf_write\": \"Drinks can be brought in but alcohol is prohibited.\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"comment\":\"==barcode==\"},\n        {\"pos\": [260, 930], \"codabar\": [\"0004693003005000\", 3, 100]},\n        {\"pos\": [160, 1000], \"expansion\": [1,1], \"bold_text\": \"0004693003005000\"},\n        {\"comment\":\"==ticket parted==\"},\n        {\"pos\": [780, 1610], \"expansion\": [2500], \"ttf_write\": \"TEST\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [670, 1610], \"expansion\": [2500], \"ttf_write\": \"CONSERT\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [620, 1630], \"expansion\": [2000], \"ttf_write\": \"Friday, February 14, 2014 14:00\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [580, 1630], \"expansion\": [2000], \"ttf_write\": \"14:00\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [420, 1610], \"expansion\": [2000], \"ttf_write\": \"Free seat\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"pos\": [330, 1600], \"expansion\": [2000], \"ttf_write\": \"$5.00\", \"font\": \"mplus-1p-medium.ttf\"},\n        {\"print\": 1}\n    ]\n]\n```\n\nPython:\n\n```Python\nfrom sbpl import *\n\njson_str = \"(defined above)\"\ncomm = SG412R_Status5()\ngen = LabelGenerator()\nparser = JsonParser(gen)\nparser.parse(json_str)\nparser.post(comm)\n```\n\n## Multiple Page Json\n\nThe Json format can include multiple pages of label data. Since Json is an entire array, you just have to add the data of the next page as the third and subsequent elements.\n\n```JSON\n[\n    {\"host\":\"192.168.0.251\", \"port\": 1024, \"communication\": \"SG412R_Status5\"},\n    [\"1st page\"],\n    [\"2nd page\"],\n    [\"3rd page\"]\n    ...\n]\n```\n\n## License\n\nMIT\n\n## Author\n\nCopyright 2018 KATO Kanryu(k.kanryu@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanryu%2Fsbpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanryu%2Fsbpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanryu%2Fsbpl/lists"}