{"id":13650347,"url":"https://github.com/djipco/hpgl","last_synced_at":"2025-04-13T12:04:53.661Z","repository":{"id":57267048,"uuid":"71740758","full_name":"djipco/hpgl","owner":"djipco","description":"A Node.js library to communicate with HPGL-compatible plotters and printers.","archived":false,"fork":false,"pushed_at":"2022-12-21T14:21:15.000Z","size":547,"stargazers_count":37,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-02T01:17:40.564Z","etag":null,"topics":["hpgl","pen-plotter"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/djipco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-24T01:22:15.000Z","updated_at":"2024-02-04T12:29:27.000Z","dependencies_parsed_at":"2023-01-30T03:45:18.582Z","dependency_job_id":null,"html_url":"https://github.com/djipco/hpgl","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djipco%2Fhpgl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djipco%2Fhpgl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djipco%2Fhpgl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djipco%2Fhpgl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djipco","download_url":"https://codeload.github.com/djipco/hpgl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240072101,"owners_count":19743527,"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":["hpgl","pen-plotter"],"created_at":"2024-08-02T02:00:36.029Z","updated_at":"2025-02-23T10:32:07.167Z","avatar_url":"https://github.com/djipco.png","language":"JavaScript","readme":"# hpgl\n**A Node.js library to control HPGL-compatible plotters**\n\n[![npm](https://img.shields.io/npm/v/hpgl.svg)](https://www.npmjs.com/package/hpgl)\n[![npm](https://img.shields.io/npm/dt/hpgl.svg)](https://www.npmjs.com/package/hpgl)\n\n### About\n\nThe `hpgl` library makes it possible to interact with plotters that support the *Hewlett-Packard \nGraphics Language* (a.k.a. **hpgl**). This language is the *de facto* standard for most plotters. \n\n**Warning: This library is still in early stages of development. It should not be used in \nproduction.**\n\n### Compatibility\n\nThis library relies on external modules for serial communication. To use it in a pure Node.js, \nenvironment, you will need to install and use the \n[serialport](https://www.npmjs.com/package/serialport) module. If you want to use this library \ninside [Chrome Apps](https://developer.chrome.com/apps/about_apps) or [NW.js](http://nwjs.io/)\napplications, you will need to install the [browser-serialport](https://www.npmjs.com/package/browser-serialport) \nmodule instead (**version 2.1.0 or greater**). \n\n\u003e *Note: it is possible to use `node-serialport` within NW.js and Electron projects but it needs to \n\u003e be specifically recompiled for those environment.*\n\nSo far, the library has only beed tested with [HP 7475A](http://hpmuseum.net/display_item.php?hw=74), \n[HP 7440A](http://hpmuseum.net/display_item.php?hw=80) and \n[Roland DXY-1300](https://archive.org/details/rolanddxy130012001100commandreferencemanualaf**) \nplotters. If you have success with other makes or models, [let me know](https://twitter.com/djipco). \nBeware that some HP plotters are only equipped with a proprietary HPIB or GPIB interface. To use \nthis library, your plotter must have a **serial** interface (RS-232-C).\n\n### Coordinate System\n\nThe plotting coordinate system is anchored in the top-left corner, just like a computer screen. \nThis means positive `x` goes right and positive `y` goes down. By default, plotters usually work \ndifferently, but I find it easier to stick with the computer screen standard.\n\n### Getting Started\n\nTo get started, you will need a few pieces of hardware:\n\n- HPGL-compatible plotter with a serial interface;\n- USB-to-Serial adapter (unless your computer has a serial port);\n- Male DB-25 to female DB-9 cable (a.k.a. null modem cable);\n- Pens that fit your plotter;\n- Paper.\n\nYour plotter needs to be set to a line speed of 9600 baud with \n[8-N-1](https://en.wikipedia.org/wiki/8-N-1) settings. Chances are high this is already the case. If\nnot, you may need to adjust some dip switches on your device. Refer to the manufacturers's \ndocumentation.\n\n### Example\n\nThe first thing you need to do to get plotting is instantiate the object used for serial \ncommunication. If you are working on a Node.js project using the `serialport` module, this is how \nyou would do it:\n\n```javascript\n// Import the 'serialport' module and instantiate it. Do not forget to set 'autoOpen' to false in \n// the options.\nconst SerialPort = require(\"serialport\");\nvar transport = new SerialPort(\"/dev/tty.usbserial\", {autoOpen: false});\n\n```\n\nIf you are working on a Chrome or NW.js application, the procedure is slightly different:\n\n```javascript\n// Import the 'browser-serialport' module and instantiate it. Pass 'false' as the third parameter of\n// the SerialPort constructor so no automatic connection attempt is made.\nconst SerialPort = require(\"browser-serialport\").SerialPort;\nvar transport = new SerialPort(\"/dev/tty.usbserial\", {}, false);\n```\n\nOnce the `transport` variable is ready, the remainining of the code is exactly the same no matter\nwhich transport you use. For example, here is the code necessary to draw \"Hello, World!\".\n\n```javascript\n\n// Import the 'Plotter' class and instantiate it\nconst Plotter = require(\"hpgl\").Plotter;\nvar plotter = new Plotter();\n\n// Connect the device and add a callback to draw some text.\nplotter.connect(transport, {}, function(error) {\n\n  if (error) {\n    console.log(error);\n    return;\n  }\n\n  this\n    .moveTo(1, 1)\n    .drawText(\"Hello, World!\");\n\n});\n```\n\nAs you can see above, you first need to create a `Plotter` object and call its `connect()` method \npassing in the `transport` variable, some optionnal settings and a function to trigger once the \ndevice is ready. Note that `this` is bound to the `Plotter` object and that plotting methods are \nchainable.\n\n### Using Multiple Plotters\n\nThis library can be used to connect several plotters to the same host. However, not all \nUSB-to-Serial chipsets support this. \n\nFor example, the Prolific 2303 driver crashes my computer when I try use more than one adapter. On \nthe other hand, the Texas Instrument/TI driver works beautifully with multiple devices.\n\n### Documentation\n\nI will try to maintain an up-to-date [API documentation](https://djipco.github.io/hpgl/). A good\nplace to start is the [Plotter class](https://djipco.github.io/hpgl/Plotter.html). If you find\nerrors, please [file an issue](https://github.com/djipco/hpgl/issues) on GitHub.\n\n## Support the Project\n\nIf you find this library useful, you can 💜 [**sponsor the project**](https://github.com/sponsors/djipco)\nas a token of your appreciation. This would automatically make you even more awesome than you already \nare!\n\nCheers!\n","funding_links":["https://github.com/sponsors/djipco"],"categories":["Software"],"sub_categories":["HPGL"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjipco%2Fhpgl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjipco%2Fhpgl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjipco%2Fhpgl/lists"}