TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Writing a printer driver in JavaScript

103 点作者 pastudan超过 3 年前

8 条评论

notpachet超过 3 年前
As someone who has spent an unfortunate amount of time working on shipping label software for ecommerce companies, my advice is to stay the hell away from ZPL. It&#x27;s the layout language equivalent of C -- too many low-level footguns. Just send 4x6 PDF&#x27;s to your thermal printer and be done with it. There are so many more tools, of much better quality, available for composing PDF&#x27;s than you&#x27;ll ever find for ZPL or other vendor-specific layout languages.<p>Sure, if you know you&#x27;re always going to be using a Zebra printer, and you control the whole pipe from software to the physical label, then you&#x27;re going to have a lot more explicit control if you use ZPL over a PDF. But the second any of those presuppositions change, it&#x27;s back to the drawing board. (Actually, even the Zebra assumption isn&#x27;t sound, because they themselves are not always 100% reliable in following their own specifications. And the specifications... boy howdy.)<p>The old argument in favor of ZPL is that you can be much more precise with the instructions you&#x27;re sending to your thermal, resulting in higher print quality, and therefore more reliable barcode scans and OCR. But the world doesn&#x27;t stand still, and shipping carriers have been steadily improving their scanning capabilities over the last 20 years, even while thermal printer capabilities have remained largely stagnant. After all, USPS has to also optimize for people who are printing labels on shitty desktop inkets. The increase in barcode quality you&#x27;d get out of using ZPL is overkill.<p>TLDR: Save yourself a lot of heartache and just sling PDF&#x27;s. Postscript&#x2F;Ghostscript is so much easier to cajole into cooperation.
评论 #30167386 未加载
评论 #30164658 未加载
评论 #30201992 未加载
jhallenworld超过 3 年前
It&#x27;s amazing how old ZPL is. I wrote a Zebra-140 driver (in C..) in something like 1993.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jhallen&#x2F;joes-sandbox&#x2F;tree&#x2F;master&#x2F;doc&#x2F;zebra" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jhallen&#x2F;joes-sandbox&#x2F;tree&#x2F;master&#x2F;doc&#x2F;zebr...</a><p>It&#x27;s a simple macro-based typesetting language that can be used to quickly make many different label images from a database. You uploaded the compiled labels into a handheld computer so that labels could be printed on a production line. One option for the computer was the Psion Organizer II.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Psion_Organiser" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Psion_Organiser</a>
mschuster91超过 3 年前
&gt; But in this tarball&#x27;s filter directory there are only x64 and x86 filters.<p>For next time you are stuck with that problem: qemu + binfmt_misc can transparently run cross-architecture apps, see <a href="https:&#x2F;&#x2F;ownyourbits.com&#x2F;2018&#x2F;06&#x2F;13&#x2F;transparently-running-binaries-from-any-architecture-in-linux-with-qemu-and-binfmt_misc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ownyourbits.com&#x2F;2018&#x2F;06&#x2F;13&#x2F;transparently-running-bin...</a>
评论 #30164733 未加载
bauerd超过 3 年前
Similarly, some years ago I prototyped an ESC&#x2F;POS client (?) for a Bluetooth thermal printer. It was implemented as a Chrome Extension&#x2F;Chrome App pair, because only Apps were allowed to use Chrome&#x27;s proprietary Bluetooth API back then. Extension and App communicated via postMessage IIRC. I was shocked how well that hack actually worked. Google then sunset Chrome Apps, and Web Bluetooth never happened.
评论 #30200642 未加载
mikece超过 3 年前
The phrase &quot;Just because you <i>can</i> doesn&#x27;t mean you <i>should</i>&quot; immediately comes to mind.
frankenst1超过 3 年前
Misleading title. &quot;Printer driver&quot; suggests a piece of software which makes the printer accessible for other programs. The software in this article merely converts an image into a different format.
评论 #30164871 未加载
评论 #30165277 未加载
davman超过 3 年前
I did something pretty similar for a Brother thermal printer, it took a couple of weeks and I completely lost my mind at one point when I tried to print a single pixel and it ended up as a gigantic block... <a href="https:&#x2F;&#x2F;daveirvine.me&#x2F;#ninety_bytes_is_720_bits" rel="nofollow">https:&#x2F;&#x2F;daveirvine.me&#x2F;#ninety_bytes_is_720_bits</a>
kotaKat超过 3 年前
&gt; But I bought this Polono label printer off Amazon for ~$140, which was a steal compared to the Zebra models that start around $500.<p>Secret: Go to Alibaba and find suppliers that will sell you a Zebra ZP888 for around ~$125&#x2F;unit. They&#x27;re a Chinese-market version of the venerable LP2844, a workhorse in the shipping industry for over two decades now, and they&#x27;re <i>brand new</i>.<p>Edit: Also forgot: If you use a service like Shippo (<a href="https:&#x2F;&#x2F;goshippo.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;goshippo.com&#x2F;</a>), you can get an API that&#x27;ll dump ZPL shipping labels out. Chain your warehouse system to Shippo for the label, then chain the ZPL out to the script and out to the printer.