{"id":22059227,"url":"https://github.com/opentable/star-printing","last_synced_at":"2025-10-23T13:03:40.060Z","repository":{"id":15142109,"uuid":"17869464","full_name":"opentable/star-printing","owner":"opentable","description":"Star print queue and persistence for iOS and Mac","archived":true,"fork":false,"pushed_at":"2017-09-28T18:02:43.000Z","size":3876,"stargazers_count":40,"open_issues_count":9,"forks_count":16,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-06-18T04:04:32.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-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/opentable.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":"2014-03-18T14:45:46.000Z","updated_at":"2024-12-01T05:09:06.000Z","dependencies_parsed_at":"2022-08-29T18:41:31.191Z","dependency_job_id":null,"html_url":"https://github.com/opentable/star-printing","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/opentable/star-printing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fstar-printing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fstar-printing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fstar-printing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fstar-printing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/star-printing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fstar-printing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266774717,"owners_count":23982246,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-30T17:27:41.207Z","updated_at":"2025-10-23T13:03:40.052Z","avatar_url":"https://github.com/opentable.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StarPrinting\n\nStar print queue and persistence for iOS and Mac\n\n## Overview\n\nStarPrinting is a CocoaPod for iOS and Mac OS X that is built on top of the StarMicronics [StarIO SDK](http://www.starmicronics.com/support/technologycategorydetail.aspx?id=39). It provides a robust, yet easy-to-use framework for integrating printing into your applications.\n\n##### Persistent Print Queue\nEach printer that your application connects to keeps a queue of all attempted print jobs that is persistent and can only be lost if the application is killed. Print jobs that were never completed will retry for several minutes on a backround thread. If they continue to fail, they will remain paused in the queue until the printer is back online.\n\n##### Real-time Status Updates\nEach printer also has a heartbeat that updates the printer status every few seconds.\n\nThe possible printer statuses are:\n\n - `PrinterStatusConnected` - Online and ready to print\n - `PrinterStatusConnecting` - Establishing a connection to printer\n - `PrinterStatusDisconnected` - Available with no errors but not connected\n - `PrinterStatusLowPaper` - Almost out of paper\n - `PrinterStatusOutOfPaper` - No paper in printer\n - `PrinterStatusCoverOpen` - Cover of printer is open\n - `PrinterStatusConnectionError` - Could not establish a connection to the printer\n - `PrinterStatusLostConnectionError` - Lost connection to the printer (probably due to the power being turned off or losing connection from network)\n - `PrinterStatusPrintError` - Invalid print data sent to printer\n - `PrinterStatusIncompatible` - Printer is not compatible with current version of StarPrinting\n - `PrinterStatusUnkownError` - An unknown error was encountered\n\n## Installation\n\nYou can install StarPrinting like any other CocoaPod.\nSee [cocoapods.org](http://cocoapods.org/) for instructions on installing and using CocoaPods.\n\n## Usage\n\n### Importing\nThe following import statement is the only one you will ever need. It will import all the necessary header files from the pod.\n\n```objective-c\n#import \u003cStarPrinting/StarPrinting.h\u003e\n```\n\n### Initializing\nThe best way to initialize a printer is to call the class method `[Printer search:(PrinterSearchBlock)block]` which returns an array of printer objects. Once you have connected to a printer, you can simply call the class method `[Printer connectedPrinter]`.\n\n### Searching\nTo search for available printers, use the class search method, passing in a result block.\n\n```objective-c\n[Printer search:^(NSArray *listOfPrinters) {\n\t// do something with the list of printers\n}];\n```\n\n### Printer Delegates\nStarPrinting also provides a printer delegate protocol so that an application can listen for status changes. Each printer delegate must implement the following method:\n\n```objective-c\n@interface MyClass : NSObject \u003cPrinterDelegate\u003e\n```\n\n```objective-c\n- (void)printer:(Printer *)printer didChangeStatus:(PrinterStatus)status\n{\n\t// update UI based on new printer status\n}\n```\n\n### Printing\nStarPrinting uses XML files to store print data. When any print method is called, it parses the XML, encodes the data into a printer-friendly format, and lastly sends it off to be printed. Example XML files can be found in the [StarPrintingExample/samples](StarPrintingExample/samples) folder. You can find a list of acceptable XML tags [here](#list-of-xml-tags).\n\nTo send data to the printer, you must create a `PrintData` object. `PrintData` is a wrapper object that has two properties:\n\n - `NSString` filePath\n - `NSDictionary` dictionary\n\nThe file path tells the printer where the XML file is located and the dictionary stores variable data to be consummed dynamically into the XML file.\n\n#### Print Test\nTo print out a test sheet, simply call the `printTest` method on the printer. This is an example where the printer creates the `PrintData` wrapper object for you. The test sheet xml file is included in the [samples](StarPrintingExample/samples) folder.\n\n```objective-c\n[[Printer connectedPrinter] printTest];\n```\n\n#### Print Static XML Files\nTo print an XML file, you will need to create a `PrintData` object and pass it to the print method. For static XML files, simply pass in `nil` for the dictionary. \n\n```objective-c\nNSString *filePath = [NSBundle mainBundle] pathForResource:@\"static_receipt\" ofType:@\"xml\"];\n\nPrintData *printData = [[PrintData alloc] initWithDictionary:nil atFilePath:filePath];\n[[Printer connectedPrinter] print:printData];\n```\n\n#### Print Dynamic XML Files\nFor dynamic XML files, you will need to include a dictionary containing each variable you want to pass in.\n\n```objective-c\nNSString *filePath = [NSBundle mainBundle] pathForResource:@\"dynamic_receipt\" ofType:@\"xml\"];\n\nNSDictionary *dictionary = @{\n\t\t\t\t\t\t\t  @\"{{day}}\" : self.day,\n\t\t\t\t\t\t\t  @\"{{month}}\" : self.month,\n\t\t\t\t\t\t\t  @\"{{year}}\" : self.year\n\t\t\t\t\t\t\t};\n\nPrintData *printData = [[PrintData alloc] initWithDictionary:dictionary atFilePath:filePath];\n[[Printer connectedPrinter] print:printData];\n```\n\nIn the XML file, variables are created using double curly-brace syntax: `{{var}}`.\n\nThe following is an example XML file that requires a day, month, and year variable:\n\n```xml\n\u003cprint\u003e\n\u003ctext\u003e\u003cbold\u003eThe current day is: \u003c/bold\u003e\u003c/text\u003e\n\u003ctext\u003e{{month}}-{{day}}-{{year}}\u003c/text\u003e\n\u003c/print\u003e\n```\n\n#### The Printable Protocol\nOne of the most powerful tools StarPrinting provides is the ability to conform to the `Printable` protocol from any Objective-C class. All classes that conform to `Printable` must implement the `printedFormat` method. This method simply returns a `PrintData` object. When `print` is called on an instance of a printable class, it will automatically call `printedFormat` and send that data to the printer.\n\nConforming to the protocol:\n```objective-c\n@interface MyDateClass : NSObject \u003cPrintable\u003e\n```\n\nImplementing the method:\n```objective-c\n- (PrintData *)printedFormat\n{\nNSString *filePath = [NSBundle mainBundle] pathForResource:@\"dynamic_receipt\" ofType:@\"xml\"];\n\nNSDictionary *dictionary = @{\n\t\t\t\t\t\t\t  @\"{{day}}\" : self.day,\n\t\t\t\t\t\t\t  @\"{{month}}\" : self.month,\n\t\t\t\t\t\t\t  @\"{{year}}\" : self.year\n\t\t\t\t\t\t\t};\n\nreturn [[PrintData alloc] initWithDictionary:dictionary atFilePath:filePath];\n}\n```\n\nCalling print on the object:\n\n```objective-c\n[myDateObject print];\n```\n```objective-c\n[myDateObject print:printer];\n```\n\n## List of XML tags\nThe following are all acceptable tags to include in your XML files. Each one has a longhand and a shorthand.\n - `\u003ctext\u003e` `\u003ct\u003e` - Any printable text (all other text formatting tags must be nested in this one)\n - `\u003cbold\u003e` `\u003cb\u003e` - Bold text\n - `\u003cunderline\u003e` `\u003cul\u003e` - Underlined text\n - `\u003cupperline\u003e` `\u003cupl\u003e` - Upperlined text\n - `\u003clarge\u003e` `\u003clg\u003e` - Large text\n - `\u003cinvertcolor\u003e` `\u003cic\u003e` - Inverted color\n - `\u003ccenter\u003e` `\u003cc\u003e` - Centered Alignment\n - `\u003cleft\u003e` `\u003cl\u003e` - Left Alignment\n - `\u003cright\u003e` `\u003cr\u003e` - Right Alignment\n - `\u003cbarcode /\u003e` `\u003cbc /\u003e` - Barcode\n - `\u003ctab /\u003e` `\u003ctb /\u003e` - Tab\n - `\u003cdashednewline /\u003e` `\u003cdl /\u003e` - Dashed new line\n - `\u003cnewline /\u003e` `\u003cnl /\u003e` - New line\n\n## Examples\n\nA sample application is inlcuded that demonstrates how to connect to the printer, display error messages based on printer status, and print out custom data.\n\n## Contributors\n\nStarPrinting was created by [Matt Newberry](https://github.com/MattNewberry) and [Will Loderhose](https://github.com/Will-Loderhose).\n\n## License\n\nStarPrinting is available under the MIT license. See the LICENSE file for more info.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fstar-printing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fstar-printing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fstar-printing/lists"}