{"id":18282804,"url":"https://github.com/chrishanzlik/zplforge","last_synced_at":"2026-03-05T00:32:04.807Z","repository":{"id":55738363,"uuid":"310208166","full_name":"chrishanzlik/ZPLForge","owner":"chrishanzlik","description":"Library for generating and serializing ZPL II code with C#","archived":false,"fork":false,"pushed_at":"2023-10-26T15:49:01.000Z","size":127,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T07:04:58.883Z","etag":null,"topics":["csharp","labels","lib","netstandard20","price-tag","zebra","zpl","zpl-to-xml","zpl2","zplforge"],"latest_commit_sha":null,"homepage":"https://github.com/chrishanzlik/ZPLForge","language":"C#","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/chrishanzlik.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":"2020-11-05T06:21:33.000Z","updated_at":"2025-02-26T08:04:49.000Z","dependencies_parsed_at":"2024-11-05T13:08:50.469Z","dependency_job_id":"0c38bc9a-be78-4924-af68-7d575e1a00cf","html_url":"https://github.com/chrishanzlik/ZPLForge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishanzlik%2FZPLForge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishanzlik%2FZPLForge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishanzlik%2FZPLForge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishanzlik%2FZPLForge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrishanzlik","download_url":"https://codeload.github.com/chrishanzlik/ZPLForge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299766,"owners_count":20916183,"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":["csharp","labels","lib","netstandard20","price-tag","zebra","zpl","zpl-to-xml","zpl2","zplforge"],"created_at":"2024-11-05T13:06:18.169Z","updated_at":"2026-03-05T00:32:04.749Z","avatar_url":"https://github.com/chrishanzlik.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](assets/logo.jpg)\n\n| Package                       | Target framework  | NuGet                                                                                                                                   | CI Build                                                                                    |\n| ----------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |\n| **ZPLForge**                  | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/ZPLForge.svg)](https://www.nuget.org/packages/ZPLForge/)                                       | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) |\n| **ZPLForge.XmlSerialization** | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/ZPLForge.XmlSerialization.svg)](https://www.nuget.org/packages/ZPLForge.XmlSerialization/)     | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) |\n\n\n##### What is ZPLForge?\n\nThe ZPLForge library for people who do not want to deal directly with **ZPL II** or read the\ndocumentation for hours. ZPLForge creates ZPL code in no time with special builders that\nguides the user in easy steps.\nAnother advantage is the XML serialization which comes with the\n*ZPLForge.XmlSerialization* package. With this, the label is saved in XML format\nin a file or string that is easy to read and adaptable to third parties.\n\n##### What this library is not\n\nThis library is not intended to communicate with any kind of devices. Converting bitmaps into GRF \nis also not part of ZPLForge's responsibility. The goal is to stay lightweight and free of \ndependencies.\n\n##### Which label elements are covered by ZPLForge?\n- Text\n- Ellipse\n- Rectangle\n- Barcode (Code39, Code128, EAN8, EAN13, UPC-A, UPC-E)\n- QR Code\n- Symbol\n- Image\n- Diagonal Line\n\n*More barcode types will be added in future versions.*\n\n## Label builder\nUsing the `LabelBuilder` is recommended way to build labels in ZPLForge, because all required properties \non the label (including the childs) will be covered. Additionally this brings some validation.\n\n### Example\nThis example is printed on a continuous media with a total width of 60 mm on a Zebra ZD420\nprinter. This printer prints with a resolution of 203 dpi, so I calculated the total width in dots as\nfollows:   \n(60 mm / 25.4) * 203 dpi = 480 dots   \n\n*Remark: All sizes in ZPLForge are given in dots!*\n\n``` csharp\nLabel priceLabel = LabelBuilder\n    .FromCuttedContinuousMedia(480, 200, 0, MediaType.ThermalTransfer)\n    .SetQuantity(1)\n    .AdjustDarknessLevel(+12)\n    .AddText(txt =\u003e txt\n        .At(15, 30)\n        .SetContent(\"Sweet Blue Shoes\")\n        .SetFont(Font.Default, 25))\n    .AddText(txt =\u003e txt\n        .At(15, 60)\n        .SetContent(\"The Shoe Manufcaturers\")\n        .SetFont(Font.Default, 20))\n    .AddSymbol(sym =\u003e sym\n        .At(220, 60)\n        .SetSymbol(SymbolKind.TradeMark, 10, 10))\n    .AddCode128Barcode(c128 =\u003e c128\n        .At(100, 105)\n        .SetHeight(50)\n        .SetContent(\"123456789\"))\n    .AddRectangle(rect =\u003e rect\n        .At(310, 20)\n        .SetDimensions(165, 60)\n        .SetBorder(LabelColor.Black, 60))\n    .AddText(txt =\u003e txt\n        .At(310, 35)\n        .ApplyBlockMode(170, 1, BlockAlignment.Center)\n        .SetContent(\"$ 49.99\")\n        .SetFont(Font.S, 20)\n        .InvertColors())\n    .AddRectangle(rect =\u003e rect\n        .At(5, 20)\n        .SetDimensions(470, 170)\n        .SetBorder(LabelColor.Black, 1))\n    .Build();\n\nstring zpl = priceLabel.ToString();\n```\n\nZPL string generated by the builder above:\n``` zpl\n^XA^LL200^MNN,0^PW480^MMC^MD12^MTT^PQ1,0,0,N,Y^CI28^PR2,6,2^FO15,30,0^FDSweet Blue Shoes^A0I,25,^FS^FO15,60,0^FDThe Shoe Manufcaturers^A0N,20,^FS^FO220,60,0^GSN,10,10^FDC^FS^FO100,105,0^BY2,3.0,10^BCN,50,Y,N,N^FD123456789^FS^FO310,20,0^GB165,60,60,B,0^FS^FO310,35,0^FR^FD$ 49.99^ASN,20,^FB170,1,0,C^FS^FO5,20,0^GB470,170,1,B,0^FS^XZ\n```\n\nThe printed label:\n\n![example](assets/example.jpg)\n\n### Factory methods   \n\nDepending on the medium what is inserted into the printer, choose one of the factory methods below to create a `LabelBuilder` instance:\n\n``` csharp\nLabelBuilder.FromWebSensingMedia(int printWidth, PrintMode? printMode = null, MediaType? mediaType = null);\n\nLabelBuilder.FromContinuousMedia(int printWidth, int labelLength, PrintMode? printMode = null, MediaType? mediaType = null);\n\nLabelBuilder.FromCuttedContinuousMedia(int printWidth, int labelLength, int groupCutCount = 0, MediaType? mediaType = null);\n\nLabelBuilder.FromBlackMarkSensingMedia(int printWidth, int blackMarkOffset, PrintMode? printMode = null, MediaType? mediaType = null);\n```   \n   \n### Builder Extensibility\n\nAll builders are extendable by common C# extension methods:\n\n``` csharp\npublic static class BuilderExtensions\n{\n    public static ImageBuilder FromBitmap(this ImageBuilder self, Bitmap bitmap)\n    {\n        ImageElement image = (self as IContextAccessor\u003cImageElement\u003e).Context;\n        image.Content = /* insert bitmap data */;\n        image.BinaryByteCount = /* insert bitmap data */;\n        /* ... */\t\t\n        return self;\n    }\n}\n```\n\n## Usage without builders\n\nTo get full control over the label and to be able to set all properties manually, the\n`Label` (including the content elements like `TextElement`) class can be used directly.\nThis would make it possible to create your own builders.\n\n``` csharp\nLabel priceLabel = new Label {\n    Quantity = 1,\n    PrintWidth = 480,\n    MediaTracking = MediaTracking.Continuous,\n    MediaType = MediaType.ThermalTransfer,\n    PrintMode = PrintMode.Cutter,\n    MediaDarknessLevel = 12,\n    Content = {\n        new TextElement {\n            PositionX = 15,\n            PositionY = 15,\n            Content = \"Sweet Blue Shoes\",\n            CharHeight = 25\n        },\n        new BarcodeElement {\n            BarcodeType = BarcodeType.Code128\n            /* ... */\n        }\n        /* ... */\n    }\n};\n```\n\n## XML Serialization\n\n### Serialization\n\nTo save the information in a human readable format without knowing much about ZPL, take a\nlook at the `LabelXmlSerializer` class inside the *ZPLForge.XmlSerialization*\npackage.\n\n``` csharp\nusing var fileStream = File.Create(\"priceLabel.xml\");\nvar serializer = new LabelXmlSerializer();\nserializer.Serialize(fileStream, priceLabel);\n```\n\nThis will output the `Label` and its content in easy to read (and editable) XML format:\n\n``` xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cLabel version=\"1.0.0\"\u003e\n  \u003cMediaTracking\u003eContinuous\u003c/MediaTracking\u003e\n  \u003cPrintWidth\u003e480\u003c/PrintWidth\u003e\n  \u003cPrintMode\u003eCutter\u003c/PrintMode\u003e\n  \u003cMediaType\u003eThermalTransfer\u003c/MediaType\u003e\n  \u003cMediaDarknessLevel\u003e12\u003c/MediaDarknessLevel\u003e\n  \u003cContent\u003e\n    \u003cText\u003e\n      \u003cPositionX\u003e15\u003c/PositionX\u003e\n      \u003cPositionY\u003e30\u003c/PositionY\u003e\n      \u003cContent\u003eSweet Blue Shoes\u003c/Content\u003e\n      \u003cCharHeight\u003e25\u003c/CharHeight\u003e\n    \u003c/Text\u003e\n    \u003cSymbol\u003e\n      \u003cPositionX\u003e215\u003c/PositionX\u003e\n      \u003cPositionY\u003e60\u003c/PositionY\u003e\n      \u003cHeight\u003e10\u003c/Height\u003e\n      \u003cWidth\u003e10\u003c/Width\u003e\n      \u003cContent\u003eTradeMark\u003c/Content\u003e\n    \u003c/Symbol\u003e\n    \u003cBarcode\u003e\n      \u003cPositionX\u003e100\u003c/PositionX\u003e\n      \u003cPositionY\u003e105\u003c/PositionY\u003e\n      \u003cContent\u003e123456789\u003c/Content\u003e\n      \u003cHeight\u003e50\u003c/Height\u003e\n    \u003c/Barcode\u003e\n    \u003c!-- ... --\u003e\n  \u003c/Content\u003e\n\u003c/Label\u003e\n```\n\nFor serializing default values (disabled by default) set the `serializeDefaults`\nparameter on `LabelXmlSerializer` to `true`:\n\n```\nserializer.Serialize(fileStream, priceLabel, serializeDefaults: true);\n```\n\n### Deserialization\n\nThe generated XML file above can be deserialized back into the `Label` object\n with the `LabelXmlSerializer` again:\n\n``` csharp\nusing var fileStream = File.OpenRead(\"priceLabel.xml\");\nvar serializer = new LabelXmlSerializer();\nLabel priceLabel = serializer.Deserialize(fileStream);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishanzlik%2Fzplforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrishanzlik%2Fzplforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishanzlik%2Fzplforge/lists"}