打印 HTML 时收据打印机上的字体大小

发布于 2024-10-05 23:38:25 字数 712 浏览 5 评论 0原文

我们有两台 Epson TMU 220 (USB) 打印机,并尝试从两个不同的客户端进行打印。一个是 Ubuntu 客户端,另一个是 Windows 客户端。使用 PHP,在 Ubuntu 中我将纯文本回显到 /dev/usb/lp0 ,一切都很好。标准的固定宽度字体,尺寸合适。作为收据打印的新手,我不知道如何添加格式,但这目前不是问题 - 我只需要普通收据。

现在,在 Windows 中我不知道如何“回显”打印机。但在 Windows 中,有可用的驱动程序(Ubuntu 则不然)。因此操作系统可以识别打印机并将其显示给用户。现在,我让 Windows 中的用户使用 FILE > Firefox(它是一个基于网络的系统)中的打印选项可打印到收据打印机。但这是诀窍。显然我的输出是呈现为 HTML 的纯文本,因此不考虑换行符。为了解决这个问题,我在文本前面放置了一个“pre”标签。现在它的轮廓非常好。然而,在 Windows 上打印时,字体很小,难以阅读。

如何改变这一点?我尝试过:

  • 使用 CSS 更改字体大小。但正如打印时所说的“调整到页面”,它总是缩小到很小的尺寸。
  • 更改“调整到页面”设置并将其保留为 100%。现在文本不适合收据(并非所有列都会打印)。
  • 使用不同的 Courier 版本更改所使用的字体。没有结果。

有人知道如何增加文本大小吗? (或者,如何直接在 Windows 上将纯文本打印到这台打印机...这也可以修复它)...

谢谢!

We have two Epson TMU 220 (USB) printers and try to print from two different clients. One is an Ubuntu client and another is a Windows client. Using PHP, In Ubuntu I echo plain text to /dev/usb/lp0 and it all comes out fine. Standard fixed-width font in good size. Being new to receipt printing, I do not know how to add format but this is not a problem at this moment - I just need plain receipts.

Now, in Windows I have no idea how to 'echo' to the printer. But in Windows there are drivers available (which is not the case for Ubuntu). So the OS recognizes the printer and it shows up for users. Now, I have users in Windows use the FILE > PRINT option in Firefox (it is a web-based system) to print to the receipt printer. But here is the trick. Obviously my output was plain text rendered as HTML so newlines are not taken into consideration. To fix this, I put a "pre" tag ahead of the text. It now outlines perfectly fine. However, when printed on Windows the font is very small, hardly readable.

How to change this? I tried:

  • Using CSS to change the font-size. But as it says "Adjust to page" when printing, it is always reduced to a tiny size.
  • Changing the "Adjust to page" setting and leaving it at 100%. Now text does not fit on the receipt (not all columns are printed).
  • Changing the font used, using different Courier versions. No results.

Anybody any idea how to get the text size to increase? (Or, how to directly print plain text on Windows to this printer... that would also fix it)...

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舟遥客 2024-10-12 23:38:25

看来您有一个纯文本文件;在这种情况下,您可以使用文本编辑器打开和打印文档,而不是浏览器。记事本是每个版本的 Windows 中都包含的选项,或者您可以安装更好的编辑器(我更喜欢 EditPlus,但是有很多很多可用的选项)。

您还可以尝试将文件复制到 PRN 或 LPT1 设备,类似于在 Linux 上所做的操作,但这可能不起作用,因为大多数打印驱动程序不会将自己设置为旧的 DOS 风格的打印机端口。我见过有关共享打印机,然后使用 NET USE LPT1:\printer\sharename 连接到它的讨论,但我自己没有必要尝试一下。

It appears that you've got a plain text file; in that case you could use a text editor to open and print the document, rather than a browser. Notepad is an option included with every version of Windows, or you could install a better editor (I prefer EditPlus, but there are many many options available).

You can also try copying the file to the PRN or LPT1 device, similar to what you do on Linux, but this may not work because most print drivers don't set themselves up as old DOS-style printer ports. I've seen discussions of sharing the printer, then connecting to it using NET USE LPT1: \printer\sharename, but I haven't had any need to try that myself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文