{"id":32147242,"url":"https://github.com/scchn/swift-zpl","last_synced_at":"2026-02-21T19:34:58.099Z","repository":{"id":206720162,"uuid":"717556185","full_name":"scchn/swift-zpl","owner":"scchn","description":"A declarative ZPL library.","archived":false,"fork":false,"pushed_at":"2024-09-09T03:45:46.000Z","size":198,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-11T19:28:39.318Z","etag":null,"topics":["swift","zebra","zebra-label-printers","zebra-printers","zpl","zpl-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/scchn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-11T20:34:26.000Z","updated_at":"2025-07-10T13:37:21.000Z","dependencies_parsed_at":"2023-12-27T07:31:51.074Z","dependency_job_id":"cdaf50a5-9dfb-49d4-b059-2429a52b9e91","html_url":"https://github.com/scchn/swift-zpl","commit_stats":null,"previous_names":["scchn/swift-zpl"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/scchn/swift-zpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scchn%2Fswift-zpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scchn%2Fswift-zpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scchn%2Fswift-zpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scchn%2Fswift-zpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scchn","download_url":"https://codeload.github.com/scchn/swift-zpl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scchn%2Fswift-zpl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29691046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T18:18:25.093Z","status":"ssl_error","status_checked_at":"2026-02-21T18:18:22.435Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["swift","zebra","zebra-label-printers","zebra-printers","zpl","zpl-programming-language"],"created_at":"2025-10-21T08:55:48.070Z","updated_at":"2026-02-21T19:34:58.094Z","avatar_url":"https://github.com/scchn.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift ZPL\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fscchn%2Fswift-zpl%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/scchn/swift-zpl)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fscchn%2Fswift-zpl%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/scchn/swift-zpl)\n\n**Swift ZPL** provides a declarative interface to write [ZPL](https://developer.zebra.com/products/printers/zpl) faster, easier and safer.\n\n# Usage\n\n```swift\nimport ZPLBuilder\n\nlet zpl = ZPL {\n    LabelHome(x: 0, y: 0)\n    ChangeAlphanumericDefaultFont(font: \"A\", height: 50)\n    Field(x: 50, y: 50) {\n        FieldData(text: \"Swift ZPL\")\n    }\n}\n\nprint(zpl.string()) // ^XA^LH0,0^CFA,50,0^FO50,50^FDSwift ZPL^FS^XZ\n```\n\n[Commands](https://github.com/scchn/swift-zpl/tree/main/Sources/ZPLBuilder/Commands)\n\n[Utilities](https://github.com/scchn/swift-zpl/tree/main/Sources/ZPLBuilder/Utils)\n\n# Commands\n\n|swift-zpl|ZPL|\n|-|-|\n|[`BarcodeCode128`](/Sources/ZPLBuilder/Commands/BarcodeCode128.swift)|`^BC` and `^FD`|\n|[`BarcodeDefault`](/Sources/ZPLBuilder/Commands/BarcodeDefault.swift)|`^BY`|\n|[`BarcodeQR`](/Sources/ZPLBuilder/Commands/BarcodeQR.swift)|`^BQ` and `^FD`|\n|[`ChangeAlphanumericDefaultFont`](/Sources/ZPLBuilder/Commands/ChangeAlphanumericDefaultFont.swift)|`^CF`|\n|[`ChangeInternationalEncoding`](/Sources/ZPLBuilder/Commands/ChangeInternationalEncoding.swift)|`^CI`|\n|[`Field`](/Sources/ZPLBuilder/Commands/Field.swift)|`^FO` and `^FS`|\n|[`FieldBlock`](/Sources/ZPLBuilder/Commands/FieldBlock.swift)|`^FB`|\n|[`FieldData`](/Sources/ZPLBuilder/Commands/FieldData.swift)|`^FD`|\n|[`FieldHexadecimal`](/Sources/ZPLBuilder/Commands/FieldHexadecimal.swift)|N/A|\n|[`FieldHexadecimalIndicator`](/Sources/ZPLBuilder/Commands/FieldHexadecimalIndicator.swift)|`^FH`|\n|[`FieldOrientation`](/Sources/ZPLBuilder/Commands/FieldOrientation.swift)|`^FW`|\n|[`FieldOrigin`](/Sources/ZPLBuilder/Commands/FieldOrigin.swift)|`^FO`|\n|[`FieldParameter`](/Sources/ZPLBuilder/Commands/FieldParameter.swift)|`^FP`|\n|[`FieldReversePrint`](/Sources/ZPLBuilder/Commands/FieldReversePrint.swift)|`^FR`|\n|[`FieldSeparator`](/Sources/ZPLBuilder/Commands/FieldSeparator.swift)|`^FS`|\n|[`FieldTypeset`](/Sources/ZPLBuilder/Commands/FieldTypeset.swift)|`^FT`|\n|[`FontIdentifier`](/Sources/ZPLBuilder/Commands/FontIdentifier.swift)|`^CW`|\n|[`GraphicBox`](/Sources/ZPLBuilder/Commands/GraphicBox.swift)|`^GB`|\n|[`GraphicCircle`](/Sources/ZPLBuilder/Commands/GraphicCircle.swift)|`^GC`|\n|[`GraphicDiagonalLine`](/Sources/ZPLBuilder/Commands/GraphicDiagonalLine.swift)|`^GD`|\n|[`GraphicEllipse`](/Sources/ZPLBuilder/Commands/GraphicEllipse.swift)|`^GE`|\n|[`GraphicField`](/Sources/ZPLBuilder/Commands/GraphicField.swift)|`^GF`|\n|[`GraphicSymbol`](/Sources/ZPLBuilder/Commands/GraphicSymbol.swift)|`^GS` and `^FD`|\n|[`HostDirectoryList`](/Sources/ZPLBuilder/Commands/HostDirectoryList.swift)|`^HW`|\n|[`Hyphen`](/Sources/ZPLBuilder/Commands/Hyphen.swift)|N/A|\n|[`LabelHome`](/Sources/ZPLBuilder/Commands/LabelHome.swift)|`^LH`|\n|[`LabelLength`](/Sources/ZPLBuilder/Commands/LabelLength.swift)|`^LL`|\n|[`LabelReversePrint`](/Sources/ZPLBuilder/Commands/LabelReversePrint.swift)|`^LR`|\n|[`LabelShift`](/Sources/ZPLBuilder/Commands/LabelShift.swift)|`^LS`|\n|[`PrintDirectoryLabel`](/Sources/ZPLBuilder/Commands/PrintDirectoryLabel.swift)|`^WD`|\n|[`PrintWidth`](/Sources/ZPLBuilder/Commands/PrintWidth.swift)|`^PW`|\n|[`ScalableBitmappedFont`](/Sources/ZPLBuilder/Commands/ScalableBitmappedFont.swift)|`^A`|\n|[`SelectEncodingTable`](/Sources/ZPLBuilder/Commands/SelectEncodingTable.swift)|`^SE`|\n|[`SetDarkness`](/Sources/ZPLBuilder/Commands/SetDarkness.swift)|`~SD`|\n|[`TextBlock`](/Sources/ZPLBuilder/Commands/TextBlock.swift)|`^TB`|\n|[`UseFontNameToCallFont`](/Sources/ZPLBuilder/Commands/UseFontNameToCallFont.swift)|`^A@`|\n\n# Examples\n\n## Boxes\n\n```swift\nZPL {\n    LabelHome(x: 0, y: 0)\n    \n    let width = 50\n    let spacing = 30\n    \n    for row in 0..\u003c3 {\n        for col in 0..\u003c3 {\n            let x = width * col + spacing * (col + 1)\n            let y = width * row + spacing * (row + 1)\n            let lineWidth = col == row ? width / 2 : 1\n            \n            Field(x: x, y: y) {\n                GraphicBox(width: width, height: width, lineWidth: lineWidth)\n            }\n        }\n    }\n}\n```\n\n![boxes](https://github.com/scchn/swift-zpl/blob/main/Images/boxes.png)\n\n## Barcodes\n\n### Code 128\n\n```swift\nZPL {\n    LabelHome(x: 0, y: 0)\n    Field(x: 50, y: 50) {\n        BarcodeCode128(data: \"hello30678\", height: 100, interpretation: .bottom)\n    }\n}\n```\n\n![boxes](https://github.com/scchn/swift-zpl/blob/main/Images/code128.png)\n\n### QR code\n\n```swift\nZPL {\n    LabelHome(x: 0, y: 0)\n    Field(x: 50, y: 50) {\n        BarcodeQR(data: \"hello\", magnificationFactor: 10)\n    }\n}\n```\n\n![boxes](https://github.com/scchn/swift-zpl/blob/main/Images/qr.png)\n\n## Text \u0026 Image\n\n```swift\nlet image: UIImage = ...\nlet labelWidth = 4 * 203\nlet labelHeight = 6 * 203\n\nZPLImageEncoder.default.isCompressed = true\n\nlet zpl = ZPL {\n    LabelHome(x: 0, y: 0)\n    LabelReversePrint(enabled: true)\n    \n    let imageWidth = labelWidth / 2\n    let imageSize = ZPLGeometryUtils.size(aspectRatio: image.size, fillWidth: imageWidth)\n    \n    Field(x: 0, y: 0) {\n        GraphicField(image: image, size: imageSize)\n    }\n    Field(x: imageWidth, y: 0) {\n        GraphicField(image: image, size: imageSize)\n    }\n    Field(x: imageWidth, y: 0) {\n        GraphicBox(\n            width: imageWidth,\n            height: Int(imageSize.height),\n            lineWidth: Int(min(imageSize.width, imageSize.height))\n        )\n    }\n}\n```\n\n![image](https://github.com/scchn/swift-zpl/blob/main/Images/image.png)\n\n```swift\nlet image: UIImage = ...\nlet labelWidth = 72 * 8\nlet labelHeight = 72 * 9\nlet settings = ZPL {\n    LabelHome(x: 0, y: 0)\n    LabelReversePrint(enabled: true)\n    ChangeAlphanumericDefaultFont(font: \"A\", height: 35)\n}\nlet body = ZPL {\n    Field(x: labelWidth / 2, y: 0) {\n        GraphicBox(width: labelWidth / 2, height: labelHeight, lineWidth: labelWidth / 2)\n    }\n    \n    let imageSize = ZPLGeometryUtils.size(aspectRatio: image.size, fillWidth: labelWidth)\n    \n    Field(x: 0, y: 0) {\n        GraphicField(image: image, size: imageSize)\n    }\n    \n    Field(x: 0, y: Int(imageSize.height)) {\n        FieldBlock(width: labelWidth, lines: 1, justification: .center)\n        FieldData(text: \"Swift\")\n        Hyphen.return\n    }\n}\nlet zpl = ZPL {\n    settings\n    body\n}\n```\n\n![text\u0026image](https://github.com/scchn/swift-zpl/blob/main/Images/text_image.png)\n\n# More Commands\n\nThis package currently only contains a few commands, if you can't find what you need:\n\nYou can create a new command with just a few lines of code:\n\n```swift\nstruct NewCommand: ZPLCommandConvertible {\n    var command: String {\n        // command...\n    }\n}\n\nZPL {\n    NewCommand()\n}\n```\n\nor create a pull request to add a new command or improve/fix existing ones.\n\n# Preview\n\n[Labelary Online ZPL Viewer](https://labelary.com/viewer.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscchn%2Fswift-zpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscchn%2Fswift-zpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscchn%2Fswift-zpl/lists"}